PHP学习笔记(实用).doc_第1页
PHP学习笔记(实用).doc_第2页
PHP学习笔记(实用).doc_第3页
PHP学习笔记(实用).doc_第4页
PHP学习笔记(实用).doc_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

一款好的CMS 系统 BEESCMS* 头文件定义方式 *xxxxx 定时刷新页面if(empty($p_yanzheng)alert_back(登录失败:验证码不正确!);function delFeedbackIP()var qstr=getCheckboxItem();if(qstr=) alert(你没选中任何内容!);else if(window.confirm(你确定要删除这些评论吗?) location.href=feedback_main.php?job=delall&fid=+qstr;function checkFeedback()var qstr=getCheckboxItem();if(qstr=) alert(您没选中任何内容!);else location.href=feedback_main.php?job=check&fid=+qstr;(一)PHP*1.isset() 函数来确认是否已设置了 cookie或其他if (isset($_COOKIEuser)echo Welcome . $_COOKIEuser . !;else echo Welcome guest!;?2.cookie 创建setcookie(user, Alex Porter, time()+3600);|取出echo $_COOKIEuser;|删除cookie setcookie(user, , time()-3600);3.session *session_start() 函数必须位于 标签之前|$_SESSIONviews=1;|$_SESSIONviews;|unset($_SESSIONviews);4.count() 函数计算数组中的单元数目或对象中的属性个数。5.ucwords() 函数把字符串中每个单词的首字符转换为大写。6.intval 将字符串转换成数字 $time=intval($time)+1;7.判断文件存在否if(!file_exists) 判断文件是不是一个文件用if(!is_file(mycount.txt) 8.file_put_contents(mycount.txt,1);规定要写入数据的文件。如果文件不存在,则创建一个新文件9.$time=file_get_contents(mycount.txt); 函数把整个文件读入一个字符串中10.filemtime 表示文件的修改时间filemtime($tpl_file_path)filemtime($complie_file_path)11.require() 函数与 include() 相同,不同的是它对错误的处理方式。include() 函数会生成一个警告(但是脚本会继续执行),而 require() 函数会生成一个致命错误(fatal error)(在错误发生后脚本会停止执行)。12.strlen() 函数用于计算字符串的长度。13.substr_replace 替换字符串的子串14.substr 返回字符串的子串15.trim() 函数从字符串的两端删除空白字符和其他预定义字符。$username = trim(array_var($data, name);16.显示时间 new Date().toLocaleString();17.重定向 history.back();/ 这个话等价于history.go(-1);18.如何检测网站的压力测试 C:myenvapachebinab.exe -n 100000 -c 3 http:/localhost/test2.html19.替换字符 可以用数组$_SYSstyleid=$_GETstyleid; str_replace(array(,/,.),array(,),$_SYSstyleid);PHP*文件的操作1.fopen() 函数用于在 PHP 中打开文件|$file=fopen(welcome.txt,r) or exit(Unable to open file!);2.feof() 函数检测是否已达到文件的末端 (EOF)。循环遍历未知长度的数据时用|if (feof($file) echo End of file;3.fgets() 函数用于从文件中逐行读取文件|while(!feof($file)echo fgets($file). ;4.fgetc() 函数用于从文件逐字符地读取文件|while (!feof($file) echo fgetc($file); 5.fclose() 函数用于关闭打开的文件。|fclose($file);6.获取浏览器IP地址function getRemoteIPAddress() $ip = $_SERVERREMOTE_ADDR;return $ip;7.如果有代理服务器的情况下获取IPfunction getRealIPAddress() if (!empty($_SERVERHTTP_CLIENT_IP) / check ip from share internet$ip = $_SERVERHTTP_CLIENT_IP; elseif (!empty($_SERVERHTTP_X_FORWARDED_FOR) / to check ip is pass from proxy$ip = $_SERVERHTTP_X_FORWARDED_FOR; else $ip = $_SERVERREMOTE_ADDR;return $ip;8.获取 MySQL 时间戳$query = select UNIX_TIMESTAMP(date_field) as mydate from mytable where 1=1;$records = mysql_query($query) or die(mysql_error();while($row = mysql_fetch_array($records) echo $row;9.验证日期格式:YYYY-MM-DDfunction checkDateFormat($date) / match the format of the dateif (preg_match(/(0-94)-(0-92)-(0-92)$/, $date, $parts) / check whether the date is valid of notif (checkdate($parts2, $parts3, $parts1) return true; else return false; else return false;10.重定向 header(Location: );11.发送邮件$to = ;$subject = Your Subject here;$body = Body of your message here you can use HTML too. e.g.Bold ;$headers = From: Yourn;$headers .= Reply-To: rn;$headers .= Return-Path: rn;$headers .= X-Mailer: PHPn;$headers .= MIME-Version: 1.0 . n;$headers .= Content-type: text/html; charset=iso-8859-1 . rn;mail($to, $subject, $body, $headers);12.BASE64 编码和解码function base64url_encode($plainText) $base64 = base64_encode($plainText);$base64url = strtr($base64, +/=, -_,);return $base64url;function base64url_decode($plainText) $base64url = strtr($plainText, -_, +/=);$base64 = base64_decode($base64url);return $base64;13.JSON 处理 $json_data = array (id=1,name=John,country=Canada,work=array(Google,Oracle);echo json_encode($json_data);$json_string=id:1,name:John,country:Canada,work:Google,Oracle ;$obj=json_decode($json_string);/ print the parsed dataecho $obj-name; /displays Johnecho $obj-work0; /displays Google14.检测用户浏览器类型$useragent = $_SERVER HTTP_USER_AGENT;echo Your User Agent is: . $useragent;15.显示网页源码$lines = file(/index.php);foreach ($lines as $line_num = $line) / loop thru each line and prepend line numbersecho Line #$line_num : . htmlspecialchars($line) . n;16.调整服务器时间$now = date(Y-m-d-G);$now = strftime(%Y-%m-%d-%H, strtotime($now -8 hours);17.(二)javascript*1.数组名.split(,2) 对字符串分割2.toString() 把一个数字转换成字符串并返回结果3.toFixed() 把数字转化为字符串结果的小数点有指定的数字var a=590.7585;a=a.toFixed(2);window.alert(a);4.eval() 把一个字符串当作脚本来运行 var str=window.alert(ok);/ 把字符串当做脚本输出eval(str);5.parseInt 把字符串转成整数6.parseloat 把字符串转成小数7.isNaN 判断某个值是不是数8.prompt 写入值到浏览器9.escape 可以转码 unescape可以转回10.prototype 给所以array对象添加一个方法find(val)Atotype.find=function(val)12.遍历数组 for(var i=0;iarr1.length;i+)document.write(arr1i+ )13.javascript 提供的八个内部类Object/Array/Math/Boolean/String/RegExp/Date/Number14.length 计算字符串的长度15.substr var str3=abcdef;返回截取的字符window.alert(str3.substr(1,3); / 得到bcd window.alert(str3.substring(1,3); / 得到bc16.getElementById var div1=document.getElementById(div1); div1.style.backgroundColor=red;17.client function test1(e)window.alert(x=+e.clientX+ y=+e.clientY);18.confirm 显示一确认和取消的消息框19.setInterval() 按照指定的周期来循环调用函数或计算20.clearInterval()取消setInterval的定时21.setTimeout 指定的毫秒数后调用函数或计算表达式22.clearTimeout 取消setTimeout的定时23.screenX/Y 鼠标针对屏幕的坐标24.getElementsByName() 通过html的控件名返回对象集合 25.getElementsByTagName() 通过html的标签名返回对象集合26.createElement() 创建一个指定标签名的元素27.appendChild() 添加元素28.removeChild() 删除元素29.bgColor 文档背景色 30.background 文档背景图31.innerText 元素间的文本32.innerHtml 元素键的html代码33.onload 文档加载时触发 onunload关闭时触发 onbeforeunload 文档关闭前触发34.style document.getEleMentById(id).perty=值34.item() 方法返回位于指定索引位置的节点。35.rows table 对象的属性 返回表格所以行的一个数组 deleteRow()删除一行 insertRow()擦入一行36.cells 表格所有单元格的一个数组(针对一行)37.confirm 表示弹出选择操作 function test()var res=window.confirm(你要删除吗);if(res)window.alert(删除);elsewindow.alert(放弃删除);38.倒计时 $(myspan).innerText=parseInt($(myspan).innerText)-1;39.用户每按下一个键就去判断是不是一个数,if(event.keyCode57)window.alert(你输入的不是数);return false;-onkeypress=return test(event)40.$(#playlist :checkbox).attr(checked,true);/ 注意 冒号前要加空格41.如何获取 服务器的IP 和 本机的IP地址 echo $_SERVER PHP_SELF; echo $_SERVER SERVER_ADDR;打印客户端IP:echo $_SERVERREMOTE_ADDR; 或者: getenv(REMOTE_ADDR);打印服务器IP:echo gethostbyname()42.var 和 public 的区别 都表示定义公开的变量 但var的兼容性比较好43. 数字时钟的实现调用如下:setInterval(webjx.innerHTML=new Date().toLocaleString()+ 星期+日一二三四五六.charAt(new Date().getDay();,1000);(三)Jquery*(1)选择器1.each遍历数组2.$(#div1)得到空间对象3.$(TagName)来获取指定标签名4.$(#div1).css(background,red)设定样式|当多个时$(#id100).css(width:200px,height:180px);5.$(.class的值) css选择器 如$(body).click(fnction)6.$(p,div,span.menuitem) 指同时选择P标签.div标签.和menuitem样式的span标签元素7.$(div li) 指获取div下所以的li元素8.next() 用于获取节点之后的第一个同辈元素 nextAll用获取节点之后的全部同辈元素9.siblings() 用于获取所有同辈元素(2)过滤器1.:first 选取第一个元素 $(div:first)选取第一个 :last同上2.:even,:odd 选取奇数和偶数的元素3.$(divid)选取有id属性的4.$(divtitle=test)选取title属性的5.$(#form1:enabled)选取id为form1的表单内的所以启用元素 disabled表禁用6.$(input:checked)选取所以选中的元素(radio.checkbox) 但$(input)只获得7.$(select:selected)选取所以选中的选项的元素8.$(:text)选取所以的表单文本框 等价于$(input:type=text)9.$(:password)选取所以的密码框10.html()方法获取或设置元素的innerHTML $(#result).html($(this).css(background-color);|$(p).html(W3School);也可以修改p中间的值11.text()方法获取或设置元素的内容innerText $(#span1).text($(window).height();|$(#span2).text($(document).height();|$(span).text($(p).height();11.1: val()得到属性的值 click()表示触发 alert($(:text).val();12.attr()方法读取或设置元素的属性 $(img).attr(width);得到图像的属性$(img).attr(width,180);设定图像的属性 $(img).attr(width:50,height:80);13.append()方法来在元素的末尾追加元素|$(p).append( W3School.);| prepend末尾加 after元素之后加 before元素之前加14.remove() 删除节点 empty() 清空节点15.保存cookie:$.cookie(名字,值) 读取:var v=$.cookie(名字)(3)样式操作1.attr(class) 获取样式2.attr(class,myclass)设置样式3.addClass(myclass)追加样式 可以添加多个类addClass(第一个类 第二个类); /* * 注意 * Class 的 C 是大写啊 */4.removeClass(myclass)移除样式 $(p).removeClass(intro);5.toggleClass(myclass)切换样式$(p).toggleClass(main); (show(带参数),hide())6.visibility:visible;显示元素 visibility:hidden;隐藏元素7.replaceWith 用于替换 $(p).replaceWith(Hello world!);事件1.cilck mousedown mouseover mouseout mouseup mousemove 2.keydowm keypress keyup keyCode3.HTML事件:window的 onload abort error 4.文本框的:select change 5.选框:checked表示选中的这个6.取得焦点:focus() 失去焦点用:blur() | $(input).focus(function()$(input).css(background-color,#FFFFCC););$(input).blur(function()$(input).css(background-color,#D6D6FF);7.disabled=true;表示让某按键或其他失效disabled=false:启用8.animate 用于选择当前的动画元素 $(#box).animate(height:300px); 里面可以设定各种属性 9.change事件 $(.field).change(function()$(this).css(background-color,#FFFFCC);10.复制代码 COPY HTML11.打印文档 print(); $(document).ready(function() $(p).click(function() $(this).hide(); ););animate的用法 动态显示$(.es-carousel ul li).hover(function() $(this).children(span).animate(bottom:0px,queue:false,duration:300); $(this).children(b).animate(top:0px,queue:false,duration:300);, function() $(this).children(span).animate(bottom:-50px,queue:false,duration:300); $(this).children(b).animate(top:-20px,queue:false,duration:300););(四)HTML* margin:0 auto; border:0px solid red; width:1275px; text-align:center; height:500px; font-size:12px; font-style: italic;斜体 font-family: Arial, Helvetica, sans-serif; line-height:30px; background:#FFFEEF; background-image: url(images/back40.gif); border-collapse: collapse; border-style: solid; border-top-style:none; border: 1px dotted #000; solid border-color: #ff0000 #FD93C1 #FD93C1; background:url(././images/lang.png) no-repeat; repeat-x repeat-y float:left; auto: none; z-index: 1; overflow: hidden; position: relative;| absolute; top: 0px; left: 0px; margin: 0px 0px 0px 0px; padding: 0px; list-style: none; align=left, center, right colspan=7 跨列 rowspan=7 跨行 zoom: 1; display:block; inline; none; hidden; filter:alpha(opacity=70);-moz-opacity:0.7;-khtml-opacity: 0.7;opacity: 0.7; opacity: 0.7; 图片透明度 font-family: arial; font-family: Georgia, Palatino, serif; font-weight: normal; background-position: 0px -24px; list-style-image: url(./i/eg_arrow.gif/*tpa=/i/eg_arrow.gif*/) background-color: rgba(17, 17, 17, 0.9); 透明背景色BODY TEXT-ALIGN: center; FONT-FAMILY: 宋体; BACKGROUND: #ffffff; FONT-SIZE: 12pxUL PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0pxOL PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0pxLI PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0pxDIV TEXT-ALIGN: left; OVERFLOW: hiddenIMG BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; VERTICAL-ALIGN: top; BORDER-LEFT-WIDTH: 0px定义DIV边框 border-top-style border-right-style border-bottom-style border-left-style 因此这两种方法是等价的:p border-style: solid solid solid none;p border-style: solid; border-left-style: none; a:link, a:visited border-style: solid; border-width: 5px; border-color: transparent; a:hover border-color: gray;DIV圆角的实现 -webkit-border-radius: 5px 5px 5px 5px;-moz-border-radius: 5px 5px 5px 5px;-khtml-border-radius: 5px 5px 5px 5px;border-radius: 5px 5px 5px 5px; -webkit-border-radius: 7px 7px 7px 7px;-moz-border-radius: 7px 7px 7px 7px;-khtml-border-radius: 7px 7px 7px 7px;border-radius: 7px 7px 7px 7px;-webkit-box-shadow: 0px 2px 2px #DDDDDD;-moz-box-shadow: 0px 2px 2px #DDDDDD;box-shadow: 0px 2px 2px #DDDDDD; 图片按钮 把按钮的宽高设的和图片一样 或 #div1 自级浮动 父类如何包住 height:auto !important;/*FF*/ 父类需要设置浮动 float:left; height:1px;/*IE6*/ 或加上 :height:100%; overflow:hidden; 清除浮动 例子: #mainmargin-right:auto;margin-left:auto;padding-top:30px;height:auto !important;/*FF*/height:100px;/*IE*/background-color:#FFF;border-width:1px;border-style:solid;border-color:#000;#thumbnailsfloat:left;margin-right:auto;margin-left:auto;padding:0;background-color:#FFF;width:258px;height:162px;border-width:1px;border-style:solid;border-color:#F00;text-align:center;vertical-align:middle; 子级 子级 很明显.textlist_left的父div是.textlist,但在CSS定义.textlist的height为auto时没有起到相应的效果,当.textlist_left内容多时,即使.textlist设置了高度100%或auto,在不同浏览器下还是不能完好的自动伸展。 解决方案 : 在层的最下方产生一个高度为1的空格,可解除这个问题。图片按钮的实现代码 在线教程样式.buttons background: #FFFFFF;border: 1px solid #EEEEEE;overflow: auto;padding: 6px;margin-bottom: 20px;a.button, input.button cursor: pointer;color: #FFFFFF;line-height: 12px;font-family: Arial, Helvetica, sans-serif;font-size: 12px;font-weight: bold;background: url(banner.jpg) repeat-x;-webkit-border-radius: 7px 7px 7px 7px;-moz-border-radius: 7px 7px 7px 7px;-khtml-border-radius: 7px 7px 7px 7px;border-radius: 7px 7px 7px 7px;-webkit-box-shadow: 0px 2px 2px #DDDDDD;-moz-box-shadow: 0px 2px 2px #DDDDDD;box-shadow: 0px 2px 2px #DDDDDD;a.button display: inline-block;text-decoration: none;padding: 6px 12px 6px 12px;input.button margin: 0;border: 0;height: 24px;padding: 0px 12px 0px 12px;a.button:hover, input.button:hover background-position: 0px -25px;1.背景图的设置:2.绝对定位:style=position:absolute; 相对定位:position:relative;3.切换层:style.display=none;style.display=hide;4.网页黑白显示:bodyfilter:Gray;5.设定鼠标的形状:css(cursor,pointer)6.行高的设定 line-height: 2 line-height: 200%7.a:link color:blue;text-decoration:none;font-size:14px; a:visitedcolor:red; a:hovertext-decoration:underline;/* none */font-size:15px;color:blue;8.文本居中 text-align:center;9.图像域的设定 type=image name=imageField10.浮动框架是使用 ifarme11.网页中表格1px边框的设定方法style=border-collapse: collapse 或 style=border: 1px solid #000000;或12.

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论