$handler = fopen ('./abc.html ', ' W ');
if (!feof ($handler)) {//Read the end of the file, you can also use file_exists
mkdir ('./abc.html ', 0777);
$handler = fopen ('./abc.html ', ' W ');
}
if (is_writable ('./abc.html ')) {
$is _success = fwrite ($handler, $html);
Fclose ($handler);
Var_dump (file_get_contents (' www1.qixoo.com/abc.html '));
}
PHP file Processing (excerpt from:)
PHP provides a rich file-handling function. Document processing mainly includes:
File creation/Opening
: (Creates and) opens a file or URL address.
File Write
: Writes content to a file, which can be used safely in binary files.
: Writes to a file, equivalent to calling Fopen,fwrite and the Fclose function in turn.
: Reads the file, which can be used safely in binary files.
: Reads a row of data from the file and points the file pointer to the next line.
: Reads the file data verbatim from the file until the end of the file.
: reads the entire file into a string.
: reads the entire file into an array, and each cell in the array is the corresponding row in the file.
Check if the file exists
: Checks whether a file or directory exists.
: Checks whether the file is readable.
: Checks whether the file is writable.
: Checks whether the file can be executed.
File copy
: Copy files.
File deletion
: Delete files.
: Gets the file size.
: Gets the file type.
: Gets the file modification time.
: Closes the file pointer.
: Tests whether the file pointer is to the end of the file.
: Locates in the file pointer.
: Returns the position of the file pointer.
: Returns the location of the file pointer read/write.
Note: Please refer to the "chapter" for the processing of the catalogue.
Is_file ()
The Is_file () function is used to check if the given file name is a normal file and returns TRUE if the file exists and is normal, otherwise FALSE.
Grammar:
BOOL Is_file (string filename)
Example:
<?php
Var_dump (Is_file (' test.txt '));
Var_dump (Is_file (' php '));
?>
Run the example output:
BOOL (TRUE)
BOOL (FALSE)
Reference reading
: Checks whether the given file name is a directory.
Tips
Operation of files and directories, you need to pay attention to the file directory read, write, delete permissions.
PHP file Processing