狮子座男

导航

PHP 写文件的例子

$contents = "All the content"; 
$dir = 'c:'; 
$file_path = $dir . "\\content.txt"; 
if(is_writable($file_path)) 
{ 
    file_put_contents($file_path , $contents); 
} 
else 
{ 
    die("Directory $dir is not writable, or does not exist. Please check"); 
}

 

posted on 2014-09-03 11:34  狮子座男  阅读(155)  评论(0编辑  收藏  举报