您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

很有用的php函数_PHP教程

2025/10/24 18:44:05发布20次查看
很有用的一些函数,你可以作为源码保存,然后以后避免重复编写。
文件读取函式
   //文件读取函式
   function php_read($file_name) {
   $fd=fopen($file_name,r);
   while($bufline=fgets($fd, 4096)){
   $buf.=$bufline;
    }
   fclose($fd);
   return $buf;
    }
   ?>
文件写入函式
      //文件写入函式
   function php_write($file_name,$data,$method=w) {
   $filenum=@fopen($file_name,$method);
   flock($filenum,lock_ex);
   $file_data=fwrite($filenum,$data);
   fclose($filenum);
   return $file_data;
    }
   ?>
静态页面生成函式
   //静态页面生成函式
   function phptohtm($filefrom,$fileto,$u2u=1){
   if($u2u==1){
   $data=php_read($filefrom);
    }else{
   $data=$filefrom;
    }
   php_write($fileto,$data);
   return true;
    }
   ?>
指定条件信息数量检索函式
      //指定条件信息数量检索函式
   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;
    }
   ?>
目录删除函式
   //目录删除函式
   function del_dir($directory){
   $mydir=dir($directory);
   while($file=$mydir->read()){
   if((is_dir($directory/$file)) and ($file!=.) and ($file!=..)){
http://www.bkjia.com/phpjc/445596.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/445596.htmltecharticle很有用的一些函数,你可以作为源码保存,然后以后避免重复编写。 文件读取函式 //文件读取函式 function php_read($file_name) { $fd=fopen($file_na...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product