PHP Test files
<?php
Header ("Content-type:text/html;charest=utf-8");
$fileDir = ' upload/file/content.txt ';
Echo ' File path: '. $fileDir. ' <br/> ';
echo ' Path directory |dirname (): '. DirName ($fileDir). ' <br/> ';
echo ' path filename |basename (): '. basename ($fileDir). ' <br/> ';
echo ' File type |filetype (): '. FileType ($fileDir). ' <br/> ';
echo ' File size |filesize (): '. FileSize ($fileDir). ' <br/> ';
Echo ' File modified Time |filemtime (): '. Filemtime ($fileDir). ' <br/> ';
Echo ' <br/> ';
Echo ' absolute path |realpath (): '. Realpath ($fileDir). ' <br/> ';
Echo ' Returns the path information in array form |pathinfo ():<br/> ';
Print_r (PathInfo ($fileDir)); Echo ' <br/> ';
Echo ' <br/> ';
echo ' Copy and rename file |rename (url01,url02): Return '. Copy ($fileDir, './upload/renamecontent.txt '). ' <br/> ';
echo ' Copy file |copy (url01,url02): Return '. Copy ($fileDir, './upload/copycontent.txt '). ' <br/> ';
Echo ' delete file |unlink (URL): return ' [email protected] ('./upload/unlinkcontent.txt '). ' <br/> ';
Echo ' <br/> ';
Echo ' reads the file information in string form |file_get_contents (URL):<br/> ';
Echo file_get_contents ($fileDir). ' <br/> ';
$putContent = ' Hello word! ';
Echo ' writes a string to the file, the file does not exist automatically created, the directory must exist, |file_put_contents (URL,STR) returns the file size: ';
echo file_put_contents ('./upload/file_put_contents.txt ', $putContent). ' <br/> ';
?>
PHP returns results
File path: Upload/file/content.txt
Path directory |dirname (): Upload/file
Path file name |basename (): Content.txt
File Type |filetype (): File
File size |filesize (): 27
File modification Time |filemtime (): 1411488282
Absolute path |realpath ():D: \kuaipan\www\testphp\upload\file\content.txt
Returns the path information as an array |pathinfo ():
Array ([dirname] = upload/file [basename] = content.txt [extension] = txt [filename] = content)
Copy and rename file |rename (url01,url02): return 1
Copy file |copy (URL01,URL02): return 1
Delete file |unlink (URL): return
Read the file information in string form |file_get_contents (URL):
? Hello word! Bad word!!!
Write string to file, file does not exist automatically created, directory must exist, |file_put_contents (URL,STR) return file size: 11
Php_file file operation Simple common functions