您好,欢迎访问一九零五行业门户网

PHP写入文件实现技巧分享_PHP教程

我们知道,在php写入文件判断是否能被写:
 ?php  
$file = 'dirlist.php';   if (is_writable($file) 
== false) {   die(我是鸡毛,我不能);   }   ?>   
能写了的话可以使用file_put_contents函数实现php写入文件:
?php  $file = 'dirlist.php';  if (is_writable($file) == false) {  die('我是鸡毛,我不能');  }  $data = '我是可鄙,我想要';  file_put_contents ($file, $data);  ?>  
file_put_contents函数在php5中新引进的函数(不知道存在的话用function_exists函数先判断一下)低版本的php无法使用,可以使用如下方式实现php写入文件:
$f = fopen($file, 'w');  fwrite($f, $data);  fclose($f);  
http://www.bkjia.com/phpjc/445975.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/445975.htmltecharticle我们知道,在 php写入文件判断是否能被写: ?php $ file = 'dirlist.php' ; if(is_writable($file) ==false){ die(我是鸡毛,我不能); } ? 能写了的话可以使用...
其它类似信息

推荐信息