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...