php file PHP file opening, closing, writing judgment and execution code

WBOY
Release: 2016-07-29 08:45:18
Original
1008 people have browsed it

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";
}
?>


 PHP文件打开、关闭、写入的判断与执行代码
Programming section: Pay attention to the symbols in the Chinese and English input methods, especially the ";" after Chinese!

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template