<! DOCTYPE html>PHP// directory operation//mkdir ("./www");//Create Directory,//rmdir ("./www");//delete directory (directory must be empty to delete);//rename ("./img"); , "./phpmyadmin/img");//Move the file, the first one is the file that needs to be moved, the second is the position after the move//file overall operation//touch ("./11.txt");//Create File//copy ("./img/11.png", ". /tmp/11.png ");//Copy the file, the first one is the source file, the second one is copied to that place. Unlink ("./11.txt");//delete files. Echo file_get_contents ("http://www.baidu.com");//Read the contents of the file, either locally or remotely//echo file_put_contents ("./img/11.txt", " Hello World "); The original content overlay is overwritten by the new content//readfile ("./img/11.txt ");//Read the file and output//$attr = Files (". /www/wenjian.php ");//var_dump ($attr); Put each line of data in the file into the array//file contents operation//$fp = fopen ("./img/11.txt", "R"),//R read-only, r+ read and write, W write empty, w+ read and write, a writes to the end of the file, A + reads and writes, X creates and opens in writing; Add a B to represent operable binaries (recommended addition)//fwrite ($FP, "Ceshi");//write Content//echo fgetc ($fp);//Get the contents of the file (one character at a time to read, want to show more output several times). while (!feof ($FP))//feof (), this function is used to determine whether the pointer has reached the end of the file, if it has been pointed to the ends of the file, then the value of the feof ($fp) function is "true", that is, return a non-0 value; otherwise return 0;//{//echo fgets ($fp). "<br/>";//}//for example, output such as//echo fgets ($FP);//Read Only one line at a time,//echo fread ($FP, 10);//Read how long, length depends on the following variables. Fclose ($FP); ?></body>The Feof function example shows a diagram:
PHP file Operation Base: directory operations, file operations