Judgment and execution code for opening, closing and writing PHP files_PHP tutorial

WBOY
Release: 2016-07-21 15:29:12
Original
824 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 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 "Write to file$ filename failed";
exit();
}
echo "Writing file $filename succeeded";

fclose($handle);
}else{
echo "File $filename cannot be written";
}
?>

Judgment and execution code for opening, closing and writing PHP files_PHP tutorial
Programming section: Pay attention to the symbols in the Chinese and English input methods, especially after Chinese ";"!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323486.htmlTechArticleHow to accurately control and judge has become a "small problem" in PHP. The following is excerpted from the book statement. Copy the code The code is as follows: ?php $filename = "html/cache.txt"; $conten...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!