PHP file Processing

Source: Internet
Author: User

$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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.