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"); 

}

 

你可能感兴趣的:(PHP)