| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> php >> PHP zhong chang yong de han shu ku he yi xie xiao ji qiao

PHP zhong chang yong de han shu ku he yi xie xiao ji qiao

2008-12-19 08:07:53 编辑來源:互联网 评论
 
 
 
本文为【PHP中常用的函数库和一些小技巧】的拼音翻译版
  wen jian du qu han shi
   // wen jian du qu han shi
   function PHP_Read($file_name) {
   $fd=fopen($file_name,r);
   while($bufline=fgets($fd, 4096)){
   $buf.=$bufline;
   }
   fclose($fd);
   return $buf;
   }
   ?>
  wen jian xie ru han shi
   // wen jian xie ru han shi
   function PHP_Write($file_name,$data,$method="w") {
   filenum=@fopen($file_name,$method]$filenum=@fopen($file_name,$method);
   flock($filenum,LOCK_EX);
   $file_data=fwrite($filenum,$data);
   fclose($filenum);
   return $file_data;
   }
   ?>
  jing tai ye mian sheng cheng han shi
   // jing tai ye mian sheng cheng han shi
   function phptohtm($filefrom,$fileto,$u2u=1){
   if($u2u==1){
   $data=PHP_Read($filefrom);
   }else{
   $data=$filefrom;
   }
   PHP_Write($fileto,$data);
   return true;
   }
   ?>
  zhi ding tiao jian xin xi shu liang jian suo han shi
   // zhi ding tiao jian xin xi shu liang jian suo han shi
   function rec_exist($table,$where){
   $query="select count(*) as num from $table ".$where;
   $result=mysql_query($query) or die(nerror(1));
   $rowcount=mysql_fetch_array($result);
   $num=$rowcount["num"];
   if ($num==0){
   return false;
   }
   return $num;
   }
   ?>
  mu lu shan chu han shi
   // mu lu shan chu han shi
   function del_DIR($directory){
   $mydir=dir($directory);
   while($file=$mydir->read()){
   if((is_dir("$directory/$file")) AND ($file!=".") AND ($file!="..")){
   del_DIR("$directory/$file");
   }else{
   if(($file!=".") AND ($file!="..")){
   unlink("$directory/$file");
   //echo "unlink $directory/$file ok ";
   }
   }
   }
   $mydir->close();
   rmdir($directory);
   //echo "rmdir $directory ok ";
   }
  ?>
  mu lu ming cheng he fa xing jian ce han shi
   // mu lu ming cheng he fa xing jian ce
   function isen($str){
   $ret="";
   for($i=0;$i $p=ord(substr($str,$i,1));
   if(($p<48 & $p!=45 & $p!=46) || ($p>57 & $p<65) || ($p>90 & $p<97 & $p!=95) || $p>122){
   nerror(" bu fu he gui fan !");
   }
   $ret.=chr($p);
   }
   return $ret;
   }
   ?>
  fen ye han shi
   // fen ye han shi
   function splitlist($HALT,$LRLIST,$ECHOCNT,$paper,$table,$where,$page_id,$userid){
   global $splitstr,$sumcnt;
   if($paper=="" || $sumcnt==""){
   $query = "select count(*) as num from $table $where";
   $result = mysql_query($query);
   $row = mysql_fetch_array($result);
   $sumcnt=$row["num"];
   if($sumcnt==0){
   nerror(" gai ban nei huan mei you xuan ze fa bu xin wen !");
   }
   $paper=1;
   }
   $sumpaper=($sumcnt-$sumcnt%$ECHOCNT)/$ECHOCNT;
   if(($sumcnt%$ECHOCNT)!=0) $sumpaper+=1;
   if($sumpaper==1 && $HALT==0) return($where);
   $enwhere=base64_encode(base64_encode($where));
   if(($LRLIST*2+1) < $sumpaper){
   if(($paper-$LRLIST) < 2){
   $tract=1;
   $sub=$LRLIST*2+1;
   }else if(($paper+$LRLIST) >= $sumpaper){
   $tract=$sumpaper-($LRLIST*2);
   $sub=$sumpaper;
   }else{
   $tract=$paper-$LRLIST;
   $sub=$paper+$LRLIST;
   }
   }else{
   $tract=1;
   $sub=$sumpaper;
   }
   $uppaper=$paper-1;
   $downpaper=$paper+1;
   $startcnt=($paper-1)*$ECHOCNT;
   $where.=" limit ${ startcnt },${ ECHOCNT }";
   if($tract > 1) { $splitstr="【 << "; }
   else $splitstr="【 << ";
   for($i=$tract;$i<=$sub;$i++){
   if ($i!=$paper) $splitstr.="".$i." ";
   else $splitstr.="".$i." ";
   }
   if ($sub!=$sumpaper) $splitstr.=">> 】";
   else $splitstr.=">> 】";
   return($where);
   }
   ?>
  guan yu fen ye han shi de shi yong shuo ming
   /*
   #### jian suo fen ye han shi ####
   Int $HALT - jian suo jie guo jin fen 1 ye shi shi fou (1/0) xian shi ye ma tiao
   Int $LRLIST - ( ye ma tiao xian shi ye ma shu -1)/2
   Int $ECHOCNT - jian suo shi mei ye xian shi ji lu de shu liang
   Int $paper - ye shu , yu ti qu :$paper=$HTTP_GET_VARS[paper];
   Varchar $table - shu ju biao ming , yu fu zhi :$table="db.table";
   Varchar $where - jian suo tiao jian , yu fu zhi :$where="where field='value'";
  
   Varchar $enwhere - jiang yuan $where jin xing liang ci base64_encode() bian ma hou yi GET de fang shi ti jiao
   Varchar $splitstr - ye ma tiao shu chu zi chuan , zhi xing han shi hou zai xiang ying de wei zhi zhi xing echo $splitstr;
  
   han shi tiao yong qian xu huo qu bian liang -
   $paper=$HTTP_GET_VARS[paper];
   $sumcnt=$HTTP_GET_VARS[sumcnt];
   $enwhere=$HTTP_GET_VARS[enwhere];
  
   Return (Varchar $where) - fen ye hou jian suo yu ju de jian suo tiao jian
   zhu yi : ben han shi xu tiao yong chu cuo chu li han shi nerror($error);
   */
  tu pian wen jian shang chuan han shi
   // tu pian wen jian shang chuan han shi
   function upload_img($UploadFile,$UploadFile_name,$UploadFile_size,$UploadPath,$max_size=64){
  
   //$TimeLimit=60; // she zhi chao shi xian zhi shi jian que sheng shi jian wei 30 miao she zhi wei 0 shi wei bu xian shi
   //set_time_limit($TimeLimit);
   if(($UploadFile!= "none" )&&($UploadFile != "" )){
   $FileName=$UploadPath.$UploadFile_name;
   if($UploadFile_size <1024){
   $FileSize="(string)$UploadFile_size" . " zi jie ";
   }elseif($UploadFile_size <(1024 * $max_size)){
   $FileSize=number_format((double)($UploadFile_size / 1024), 1) . " KB";
   }else{
   nerror(" wen jian chao guo xian zhi da xiao !");
   }
   //{
   //$FileSize="number_format((double)($UploadFile_size" / (1024 * 1024)), 1) . " MB";
   // }
   if(!file_exists($FileName)){
   if(copy($UploadFile,$FileName)){
   return "$UploadFile_name ($FileSize)";
   }else{
   nerror(" wen jian $UploadFile_name shang zai shi bai !");
   }
   unlink($UploadFile);
   }else{
   nerror(" wen jian $UploadFile_name yi jing cun zai !");
   }
   //set_time_limit(30); // hui fu que sheng chao shi she zhi
   }
   }
  --------------------------------------------------------------------------------
  yi xia shi yi xie xiao ji qiao :
  --------------------------------------------------------------------------------
  ru he pan duan ip di zhi he fa xing
  if(!strcmp(long2ip(sprintf("%u",ip2long($ip))),$ip)) echo "is ipn";
  ----
  email de zheng ze pan duan
  eregi("^[_.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z_-]+.)+[a-zA-Z]$", $email);
  jian ce ip di zhi he mask shi fou he fa de li zi
  $ip = '192.168.0.84';
  $mask = '255.255.255.0';
  $network = '192.168.0';
  $ip = ip2long($ip);
  $mask = ip2long($mask);
  $network = ip2long($network);
  if( ($ip & $mask) == $network) echo "valid ip and maskn";
  ?>
  ----
  wen jian xia zai tou bu shu chu ru he she ding
  header("Content-type: application/x-download");
  header("Content-Disposition: attachment; filename=$file_download_name;");
  header("Accept-Ranges: bytes");
  header("Content-Length: $download_size");
  echo 'xxx'
  yong header shu chu ftp xia zai fang shi , bing qie zhi chi duan dian xu chuan
  yi ge li zi :
  header('Pragma: public');
  header('Cache-Control: private');
  header('Cache-Control: no-cache, must-revalidate');
  header('Accept-Ranges: bytes');
  header('Connection: close');
  header("Content-Type: audio/mpeg");
  header("Location:ftp://download:1bk3l4s3k9s2@232.2.22.22/2222/web ji shu kai fa zhi shi ku /cn_web.rmvb");
  zheng ze pi pei zhong wen
  ereg("^[".chr(0xa1)."-".chr(0xff)."]+$", $str);
  pi liang ti huan wen ben li mian de chao ji lian jie
  <?php
  function urlParse($str = ''){
   if ('' == $str) return $str;
  $types = array("http", "ftp", "https");
  $replace = <<<EOPHP
  '<a href="'.htmlentities('\1').htmlentities('\2').'">'.htmlentities('\1').htmlentities('\2').'</a>'
  EOPHP;
  $ret = $str;
  while(list(,$type) = each($types)){
  $ret = preg_replace("|($type://)([^\s]*)|ie ", $replace, $ret);
  }
  return $ret;
  }
  ?>【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
wen jian du qu han shi // wen jian du qu han shi function PHP_Read($file_name) { $fd=fopen($file_name,r); while($bufline=fgets($fd, 4096)){ $buf.=$bufline; } fclose($fd); return $buf; } ?> wen jian xie ru han shi // wen jian xie ru han shi function PHP_Write($file_name,$data,$method="w") { [url=mailto:$filenum=@fopen($file_name,$method]$filenum=@fopen($file_name,$method[/url]); flock($filenum,LOCK_EX); $file_data=fwrite($filenum,$data); fclose($filenum); return $file_data; } ?> jing tai ye mian sheng cheng han shi // jing tai ye mian sheng cheng han shi function phptohtm($filefrom,$fileto,$u2u=1){ if($u2u==1){ $data=PHP_Read($filefrom); }else{ $data=$filefrom; } PHP_Write($fileto,$data); return true; } ?> zhi ding tiao jian xin xi shu liang jian suo han shi // zhi ding tiao jian xin xi shu liang jian suo han shi function rec_exist($table,$where){ $query="select count(*) as num from $table ".$where; $result=mysql_query($query) or die(nerror(1)); $rowcount=mysql_fetch_array($result); $num=$rowcount["num"]; if ($num==0){ return false; } return $num; } ?> mu lu shan chu han shi // mu lu shan chu han shi function del_DIR($directory){ $mydir=dir($directory); while($file=$mydir->read()){ if((is_dir("$directory/$file")) AND ($file!=".") AND ($file!="..")){ del_DIR("$directory/$file"); }else{ if(($file!=".") AND ($file!="..")){ unlink("$directory/$file"); //echo "unlink $directory/$file ok "; } } } $mydir->close(); rmdir($directory); //echo "rmdir $directory ok "; } ?> mu lu ming cheng he fa xing jian ce han shi // mu lu ming cheng he fa xing jian ce function isen($str){ $ret=""; for($i=0;$i $p=ord(substr($str,$i,1)); if(($p<48 & $p!=45 & $p!=46) || ($p>57 & $p<65) || ($p>90 & $p<97 & $p!=95) || $p>122){ nerror(" bu fu he gui fan !"); } $ret.=chr($p); } return $ret; } ?> fen ye han shi // fen ye han shi function splitlist($HALT,$LRLIST,$ECHOCNT,$paper,$table,$where,$page_id,$userid){ global $splitstr,$sumcnt; if($paper=="" || $sumcnt==""){ $query = "select count(*) as num from $table $where"; $result = mysql_query($query); $row = mysql_fetch_array($result); $sumcnt=$row["num"]; if($sumcnt==0){ nerror(" gai ban nei huan mei you xuan ze fa bu xin wen !"); } $paper=1; } $sumpaper=($sumcnt-$sumcnt%$ECHOCNT)/$ECHOCNT; if(($sumcnt%$ECHOCNT)!=0) $sumpaper+=1; if($sumpaper==1 && $HALT==0) return($where); $enwhere=base64_encode(base64_encode($where)); if(($LRLIST*2+1) < $sumpaper){ if(($paper-$LRLIST) < 2){ $tract=1; $sub=$LRLIST*2+1; }else if(($paper+$LRLIST) >= $sumpaper){ $tract=$sumpaper-($LRLIST*2); $sub=$sumpaper; }else{ $tract=$paper-$LRLIST; $sub=$paper+$LRLIST; } }else{ $tract=1; $sub=$sumpaper; } $uppaper=$paper-1; $downpaper=$paper+1; $startcnt=($paper-1)*$ECHOCNT; $where.=" limit ${ startcnt },${ ECHOCNT }"; if($tract > 1) { $splitstr="【 << "; } else $splitstr="【 << "; for($i=$tract;$i<=$sub;$i++){ if ($i!=$paper) $splitstr.="".$i." "; else $splitstr.="".$i." "; } if ($sub!=$sumpaper) $splitstr.=">> 】"; else $splitstr.=">> 】"; return($where); } ?> guan yu fen ye han shi de shi yong shuo ming /* #### jian suo fen ye han shi #### Int $HALT - jian suo jie guo jin fen 1 ye shi shi fou (1/0) xian shi ye ma tiao Int $LRLIST - ( ye ma tiao xian shi ye ma shu -1)/2 Int $ECHOCNT - jian suo shi mei ye xian shi ji lu de shu liang Int $paper - ye shu , yu ti qu :$paper=$HTTP_GET_VARS[paper]; Varchar $table - shu ju biao ming , yu fu zhi :$table="db.table"; Varchar $where - jian suo tiao jian , yu fu zhi :$where="where field='value'"; Varchar $enwhere - jiang yuan $where jin xing liang ci base64_encode() bian ma hou yi GET de fang shi ti jiao Varchar $splitstr - ye ma tiao shu chu zi chuan , zhi xing han shi hou zai xiang ying de wei zhi zhi xing echo $splitstr; han shi tiao yong qian xu huo qu bian liang - $paper=$HTTP_GET_VARS[paper]; $sumcnt=$HTTP_GET_VARS[sumcnt]; $enwhere=$HTTP_GET_VARS[enwhere]; Return (Varchar $where) - fen ye hou jian suo yu ju de jian suo tiao jian zhu yi : ben han shi xu tiao yong chu cuo chu li han shi nerror($error); */ tu pian wen jian shang chuan han shi // tu pian wen jian shang chuan han shi function upload_img($UploadFile,$UploadFile_name,$UploadFile_size,$UploadPath,$max_size=64){ //$TimeLimit=60; // she zhi chao shi xian zhi shi jian que sheng shi jian wei 30 miao she zhi wei 0 shi wei bu xian shi //set_time_limit($TimeLimit); if(($UploadFile!= "none" )&&($UploadFile != "" )){ $FileName=$UploadPath.$UploadFile_name; if($UploadFile_size <1024){ $FileSize="(string)$UploadFile_size" . " zi jie "; }elseif($UploadFile_size <(1024 * $max_size)){ $FileSize=number_format((double)($UploadFile_size / 1024), 1) . " KB"; }else{ nerror(" wen jian chao guo xian zhi da xiao !"); } //{ //$FileSize="number_format((double)($UploadFile_size" / (1024 * 1024)), 1) . " MB"; // } if(!file_exists($FileName)){ if(copy($UploadFile,$FileName)){ return "$UploadFile_name ($FileSize)"; }else{ nerror(" wen jian $UploadFile_name shang zai shi bai !"); } unlink($UploadFile); }else{ nerror(" wen jian $UploadFile_name yi jing cun zai !"); } //set_time_limit(30); // hui fu que sheng chao shi she zhi } } -------------------------------------------------------------------------------- yi xia shi yi xie xiao ji qiao : -------------------------------------------------------------------------------- ru he pan duan ip di zhi he fa xing if(!strcmp(long2ip(sprintf("%u",ip2long($ip))),$ip)) echo "is ipn"; ---- email de zheng ze pan duan eregi("^[_.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z_-]+.)+[a-zA-Z]$", $email); jian ce ip di zhi he mask shi fou he fa de li zi $ip = '192.168.0.84'; $mask = '255.255.255.0'; $network = '192.168.0'; $ip = ip2long($ip); $mask = ip2long($mask); $network = ip2long($network); if( ($ip & $mask) == $network) echo "valid ip and maskn"; ?> ---- wen jian xia zai tou bu shu chu ru he she ding header("Content-type: application/x-download"); header("Content-Disposition: attachment; filename=$file_download_name;"); header("Accept-Ranges: bytes"); header("Content-Length: $download_size"); echo 'xxx' yong header shu chu ftp xia zai fang shi , bing qie zhi chi duan dian xu chuan yi ge li zi : header('Pragma: public'); header('Cache-Control: private'); header('Cache-Control: no-cache, must-revalidate'); header('Accept-Ranges: bytes'); header('Connection: close'); header("Content-Type: audio/mpeg"); header("Location:ftp://download:1bk3l4s3k9s2@232.2.22.22/2222/web ji shu kai fa zhi shi ku /cn_web.rmvb"); zheng ze pi pei zhong wen ereg("^[".chr(0xa1)."-".chr(0xff)."]+$", $str); pi liang ti huan wen ben li mian de chao ji lian jie <?php function urlParse($str = ''){ if ('' == $str) return $str; $types = array("http", "ftp", "https"); $replace = <<<EOPHP '<a href="'.htmlentities('\1').htmlentities('\2').'">'.htmlentities('\1').htmlentities('\2').'</a>' EOPHP; $ret = $str; while(list(,$type) = each($types)){ $ret = preg_replace("|($type://)([^\s]*)|ie ", $replace, $ret); } return $ret; } ?>
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
华丽的模特拍摄(8)
华丽的模特拍摄(7)
华丽的模特拍摄(6)
华丽的模特拍摄(5)
八里沟
朝阳宫
天下峨眉 云上金顶
老家(四)
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有