How to accurately control and judge has become a "small problem" in PHP. The following is a sentence excerpted from the book.
Copy the code The code is as follows:
$filename = "html/cache.txt";
$contents = "I am Zhang Bin";
if(is_writable($filename)) {
if(($handle = fopen($filename,"a") )== false){
echo "Failed to write file $filename";
exit();
}
if(fwrite($handle,$ contents) == false){
echo "Failed to write to file $filename";
exit();
}
echo "Failed to write to file $filename";
fclose($handle);
}else{
echo " File $filename cannot be written";
}
?>
The above introduces the judgment and execution code for opening, closing, and writing of PHP files, including the content of PHP files. I hope it will be helpful to friends who are interested in PHP tutorials.