Explain the example code for creating files in php:
- $data =date("Ymd");
- $dir ="/hom/kyle/file/$data";
- $filename ="/home/kyle/file/$data/testfile";
- $filecontent ="This is what to write The entered content tests the space ";
- //Determine whether the folder exists, otherwise create it
- if(!is_dir($dir)){
- mkdir($dir ,0777);
- }
- //Determine whether the file exists, otherwise create it
- if(!file_exists($filename)){ $handle=fopen($filename, w);
- if(!$handle){
- echo create file fail;
- exit;
- }else{
- chmod($filename,0777);
- }
- if(fwrite($handle, $filecontent) === FALSE) {
- echo "cant write into $filename ";
- exit;
- }
- fclose($handle);
- }
- ?>
http://www.bkjia.com/PHPjc/486174.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486174.htmlTechArticleExplains the example code for creating files in PHP: ?php $data =date("Ymd"); $dir ="/ hom/kyle/file/$data"; $filename ="/home/kyle/file/$data/testfile"; $filecontent ="This is the content to be written to test...
Statement: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