There are many File operation functions in php. I will introduce you to the usage of common file operation functions in php. 1. get the file name: basename (); 2. get the directory where the file is located: dirname (); 3. pathi... there are many File operation functions in php. I will introduce you to the usage of common file operation functions in php.
1. get the file name: basename ();
2. obtain the directory where the file is located: dirname ();
3. obtain the file information through pathinfo (). The Returned result is an array, including the path, full name, file name, and extension.
The instance code is as follows:
$file = '/com/netingcn/error.log'; print_r(pathinfo($file));
Result:
Array( [dirname] => /com/netingcn [basename] => error.log [extension] => log [filename] => error )
4. determine whether the file exists: is_file ();
5. check whether the directory exists: is_dir ();
6. determine whether a file or directory exists: file_exists ();
7. read all the file content: file () or file_get_contents (). file () returns an array with a row of elements. file_get_contents () returns all the file content as a String;
8. write the file fwrite, for example:
The instance code is as follows:
Article address:
Reprint at will ^ please include the address of this article!