PHP动态网页开发中常用的一些函数
在php网页的开头加入以下
以下为引用的内容: $time_start = getmicrotime(); function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } ?> |
然后到最后加入以下代码
以下为引用的内容: $time_end = getmicrotime(); printf ("[页面执行时间: %.2f毫秒] ",($time_end - $time_start)*1000); ?> $file = fopen($filename, r) or die("抱歉,无法打开: $filename"); |
or在这里是这样理解的,因为在php中并不区分数据类型,所以$file既可以是int也可以bool,所以这样的语句不会报错。但其处理过程可能有些朋友不大明白。
其实在大多数的语言中, bool or bool这样的语句中,如果前一个值为真后一个值就不会再判断了。这里也是的,所以如果fopen函数执行正确的话,会返回一个大于0的int值(这其实就是“真”),后面的语句就不会执行了。如果fopen函数执行失败,就会返回false,那么就会判断后面的表达式是否为真了。
结果执行了die()之后,不管返回什么,程序都已经停止执行了,并且显示指定的出错信息,也就达到了调试的目的。
php复选框的问题
以下为引用的内容: |
d.php
以下为引用的内容: $fd=$_post[checkbox]; for ($i = 0; $i $newhpt=$newhpt.$fd[$i].","; } echo $newhpt." "; ?> |
php代码中函数前面的@是什么意思?
@的作用是忽略调用该函数时产生的错误信息。
php中日期相加的问题
以下为引用的内容: $fd=$_post[checkbox]; for ($i = 0; $i $newhpt=$newhpt.$fd[$i].","; } echo $newhpt." "; ?> |
关于php水印的问题
以下为引用的内容: //读取目标文件 $im = imagecreatefromjpeg("1[2].jpg"); //设定混合模式 imagealphablending($im, true); //读取水印 $im2 = imagecreatefrompng("watermark.png"); //下面是我写的字,可以不看 //$color = imagecolorallocate($im2, 0, 0, 0); //imagestring($im2, 12, 1, 1, "i love u jingjing", $color); //字结束 //拷贝水印到目标文件 imagecopy($im, $im2, 5, 5, 0, 0, 220, 34); //输出,可以输出到文件里 imagejpeg($im); imagedestroy($im); imagedestroy($im1); ?> $im = imagecreatefromjpeg("1[2].jpg"); //$im = imagecreatefromgif("eee.gif"); //$im = imagecreatefrompng("1[2].png"); $black = imagecolorallocate ($im, 0, 140, 76); $red = imagecolorallocate ($im, 255, 0, 0); $string=chr(0xe5).chr(0xae).chr(0x89).chr(0xe5).chr(0xba).chr(0x86).chr(0xe6).chr(0x88).chr(0xbf).chr(0xe4).chr(0xba).chr(0xa7).chr(0xe7).chr(0xbd).chr(0x91); //imagestring ($im,12,10,10,$string,$red); imagettftext($im,20,0,4,30,$red,"fzdhtjw.ttf",$string); imagepng ($im); imagedestroy ($im); ?> //这个函数是把汉字转换成utf-8后,就可以在gd中使用了! function gb2utf8($gb) { if(!trim($gb)) return $gb; $filename="gb2312.txt"; $tmp=file($filename); $codetable=array(); while(list($key,$value)=each($tmp)) $codetable[hexdec(substr($value,0,6))]=substr($value,7,6); $utf8=""; while($gb) { if (ord(substr($gb,0,1))>127) { $this=substr($gb,0,2); $gb=substr($gb,2,strlen($gb)); $utf8.=u2utf8(hexdec($codetable[hexdec(bin2hex($this))-0x8080])); } else { $gb=substr($gb,1,strlen($gb)); $utf8.=u2utf8(substr($gb,0,1)); } } $ret=""; for($i=0;$i return $ret; } function u2utf8($c) { for($i=0;$i if ($c $str.=$c; } else if ($c $str.=(0xc0 | $c>>6); $str.=(0x80 | $c & 0x3f); } else if ($c $str.=(0xe0 | $c>>12); $str.=(0x80 | $c>>6 & 0x3f); $str.=(0x80 | $c & 0x3f); } else if ($c $str.=(0xf0 | $c>>18); $str.=(0x80 | $c>>12 & 0x3f); $str.=(0x80 | $c>>6 & 0x3f); $str.=(0x80 | $c & 0x3f); } return $str; } header("content-type: image/gif"); $im = imagecreate(400,300); $bkg = imagecolorallocate($im, 0,0,0); $clr = imagecolorallocate($im, 255,255,255); $fnt = "wb.ttf"; //include("gb2utf8.php"); $str = gb2utf8("中国"); imagettftext($im, 20, 0, 10, 20, $clr, $fnt, $str); imagegif($im); imagedestroy($im); ?> |
以下为引用的内容: //对javascript和select部件的结合运用 switch ($mon){ |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment