国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > PHP > 正文

PHP動(dòng)態(tài)網(wǎng)頁(yè)開(kāi)發(fā)中常用的一些函數(shù)

2020-03-24 16:19:14
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
以下為引用的內(nèi)容:
?
$time_start = getmicrotime();
function getmicrotime()
{
list($usec, $sec) = explode( ,microtime());
return ((float)$usec + (float)$sec);
}
?
以下為引用的內(nèi)容:
?
$time_end = getmicrotime();
printf ( [頁(yè)面執(zhí)行時(shí)間: %.2f毫秒]/n/n ,($time_end - $time_start)*1000);
?

$file = fopen($filename, 'r') or die( 抱歉,無(wú)法打開(kāi): $filename
or在這里是這樣理解的,因?yàn)樵趐hp中并不區(qū)分?jǐn)?shù)據(jù)類型,所以$file既可以是int也可以bool,所以這樣的語(yǔ)句不會(huì)報(bào)錯(cuò)。但其處理過(guò)程可能有些朋友不大明白。其實(shí)在大多數(shù)的語(yǔ)言中, bool or bool這樣的語(yǔ)句中,如果前一個(gè)值為真后一個(gè)值就不會(huì)再判斷了。這里也是的,所以如果fopen函數(shù)執(zhí)行正確的話,會(huì)返回一個(gè)大于0的int值(這其實(shí)就是 真 ),后面的語(yǔ)句就不會(huì)執(zhí)行了。如果fopen函數(shù)執(zhí)行失敗,就會(huì)返回false,那么就會(huì)判斷后面的表達(dá)式是否為真了。結(jié)果執(zhí)行了die()之后,不管返回什么,程序都已經(jīng)停止執(zhí)行了,并且顯示指定的出錯(cuò)信息,也就達(dá)到了調(diào)試的目的。php復(fù)選框的問(wèn)題
以下為引用的內(nèi)容:
form name= form1 method= post action= d.php
input type= checkbox name= checkbox[] html' target='_blank'>value= 111
111
input type= checkbox name= checkbox[] value= 222
222
input type= checkbox name= checkbox[] value= 3333
333
input type= checkbox name= checkbox[] value= 4444
4444
input type= checkbox name= checkbox[] value= 5555
555
input type= checkbox name= checkbox[] value= 6666
6666
input type= submit name= submit value= 提交
/form
以下為引用的內(nèi)容:
?
$fd=$_post['checkbox'];
for ($i = 0; $i (sizeof($fd)); $i++) {
$newhpt=$newhpt.$fd[$i]. ,
}
echo $newhpt. br
?
php代碼中函數(shù)前面的@是什么意思? @的作用是忽略調(diào)用該函數(shù)時(shí)產(chǎn)生的錯(cuò)誤信息。php中日期相加的問(wèn)題
以下為引用的內(nèi)容:
?
$fd=$_post['checkbox'];
for ($i = 0; $i (sizeof($fd)); $i++) {
$newhpt=$newhpt.$fd[$i]. ,
}
echo $newhpt. br
?
以下為引用的內(nèi)容:
?php
//讀取目標(biāo)文件
$im = imagecreatefromjpeg( 1[2].jpg
//設(shè)定混合模式
imagealphablending($im, true);
//讀取水印
$im2 = imagecreatefrompng( watermark.png
//下面是我寫(xiě)的字,可以不看
//$color = imagecolorallocate($im2, 0, 0, 0);
//imagestring($im2, 12, 1, 1, i love u jingjing , $color);
//字結(jié)束
//拷貝水印到目標(biāo)文件
imagecopy($im, $im2, 5, 5, 0, 0, 220, 34);
//輸出,可以輸出到文件里
imagejpeg($im);
imagedestroy($im);
imagedestroy($im1);
?
?php
$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);
?
?
//這個(gè)函數(shù)是把漢字轉(zhuǎn)換成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 strlen($utf8);$i+=3)
$ret.=chr(substr($utf8,$i,3));
return $ret;
}
function u2utf8($c)
{
for($i=0;$i count($c);$i++)
$str=/ /
if ($c 0x80) {
$str.=$c;
}
else if ($c 0x800) {
$str.=(0xc0 | $c 6);
$str.=(0x80 | $c 0x3f);
}
else if ($c 0x10000) {
$str.=(0xe0 | $c 12);
$str.=(0x80 | $c 6 0x3f);
$str.=(0x80 | $c 0x3f);
}
else if ($c 0x200000) {
$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(/ 中國(guó)/
imagettftext($im, 20, 0, 10, 20, $clr, $fnt, $str);
imagegif($im);
imagedestroy($im);
?

以下為引用的內(nèi)容:
?php
//對(duì)javascript和select部件的結(jié)合運(yùn)用
//在寫(xiě)程序的過(guò)程,我想實(shí)現(xiàn)在select對(duì)象選中選項(xiàng)后,
//不需要提交按鈕,而直接觸發(fā)動(dòng)作,且在動(dòng)作發(fā)生后
//的頁(yè)面中要保持所選擇的選項(xiàng)。經(jīng)過(guò)形容,終于通過(guò)
//使用javascript及select對(duì)象的onchange屬性及
//value值而實(shí)現(xiàn)了這種功能。
//代碼如下(文件名為 test.php ): switch ($mon){
case '': echo '請(qǐng)選擇您的星座:';break;
case '1':echo '您的星座是水瓶座';break;
case '2':echo '您的星座是雙魚(yú)座';break;
case '3':echo '您的星座是白羊座';break;
case '4':echo '您的星座是金牛座';break;
case '5':echo '您的星座是雙子座';break;
case '6':echo '您的星座是巨蟹座';break;
case '7':echo '您的星座是獅子座';break;
case '8':echo '您的星座是處女座';break;
case '9':echo '您的星座是天平座';break;
case '10':echo '您的星座是天蝎座';break;
case '11':echo '您的星座是射手座';break;
case '12':echo '您的星座是魔蝎座';break;
default:break;
}
?
form name= form1
select name= month_select
onchange= #location.href=
this.options[this.selectedindex].value
option --請(qǐng)選擇你的星座-- /option
option value= test.php?mon=1
?php if($mon== 1 ) echo selected ? 水瓶座 /option
option value= test.php?mon=2
?php if($mon== 2 ) echo selected ? 雙魚(yú)座 /option
option value= test.php?mon=3
?php if($mon== 3 ) echo selected ? 白羊座 /option
option value= test.php?mon=4
?php if($mon== 4 ) echo selected ? 金牛座 /option
option value= test.php?mon=5
?php if($mon== 5 ) echo selected ? 雙子座 /option
option value= test.php?mon=6
?php if($mon== 6 ) echo selected ? 巨蟹座 /option
option value= test.php?mon=7
?php if($mon== 7 ) echo selected ? 獅子座 /option
option value= test.php?mon=8
?php if($mon== 8 ) echo selected ? 處女座 /option
option value= test.php?mon=9
?php if($mon== 9 ) echo selected ? 天平座 /option
option value= test.php?mon=10
?php if($mon== 10 ) echo selected ? 天蝎座 /option
option value= test.php?mon=11
?php if($mon== 11 ) echo selected ? 射手座 /option
option value= test.php?mon=12
?php if($mon== 12 ) echo selected ? 魔蝎座 /option
/select
/form

?
$uploadimgurl= mag/
$showdatefilename=strftime( %y%m%d%h%m%s
if($_get[ up ]== up ){
$uploadimgname=$_files['pic']['name'];
$filecount=$_files['pic']['size'];
$max_file_size=$_post[ max_file_size
if ($filecount $max_file_size){
echo script alert(/ 您上傳的圖片太大,超過(guò)指定的大小了!請(qǐng)重新上傳!/ ) /script
}else{
$endfilename=strrchr($uploadimgname, .
$filepath=$uploadimgurl. arc .$showdatefilename.$endfilename;
if (strspn(strrchr($uploadimgname, . ), .jpgifjpgif ) 3){
move_uploaded_file($_files['pic']['tmp_name'],$filepath);
?
script
parent.input.bny.value+='[img] ?=$filepath;? [/img] br '
location.replace('upload.php')
/script
?
}else{
echo script alert(/ 您剛才上傳的圖片類型不符合要求!/ location.href=/ upload.php/ /script
}
}
}
?
以下為引用的內(nèi)容:
function char($str,$len){
$str=substr($str,0,$len);
$str_len=strlen($str);
$j=0;
for ($i=0;$i =$str_len;$i++){
if (ord(substr($str,$i,1)) 160){
$j++;
}
}
if ($j%2==0){
$str=substr($str,0,$len-1);
}
return $str;
}html教程

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 克山县| 东乡| 清镇市| 库尔勒市| 化隆| 淮阳县| 手游| 那曲县| 宁国市| 开平市| 湛江市| 英山县| 连山| 平远县| 安徽省| 萨嘎县| 武宣县| 桐柏县| 彰化县| 苍溪县| 霸州市| 肇源县| 昌图县| 津市市| 乃东县| 莱阳市| 宿州市| 仪征市| 佛山市| 突泉县| 信丰县| 黑龙江省| 深州市| 云梦县| 泰顺县| 泾源县| 吉安县| 盐城市| 乐平市| 象山县| 奉贤区|