Example of a file handle: you can use the handle to locate the starting position of a file that has not been read and block reading of large files. to use the read file function, you need to use the path relative to the PHP script to indicate the file to be read, however, most PHP file functions use a slightly different mechanism to access files. this mechanism is very similar to the mechanism for connecting to the database. in this process, the fopen () function is used for "connection ", use the fclose function to "disconnect ". The return value of the fopen function is a PHP file pointer, also known as a file handle... example of a file handle: you can use the handle to locate the starting position of a file that has not been read and block reading of large files. to use the read file function, you need to use the path relative to the PHP script to indicate the file to be read, however, most PHP file functions use a slightly different mechanism to access files. this mechanism is very similar to the mechanism for connecting to the database. in this process, the fopen () function is used for "connection ", use the fclose function to "disconnect ". The return value of the fopen function is a PHP file pointer, also known as a file handle. once you have a file handle, you can use it to perform a variety of operations on the file, including removing and attaching operations, so what problems should I pay attention to when using this handle? First, let's take a look at how the file is opened and closed. The code is as follows:
1. 10 articles about php fopen () functions are recommended.
Introduction: <? Php // PHP visitor counter function num () {if (! File_exists ("n.txt") {$ fp = fopen ("n.txt", "w"); fwrite ($ fp, "1"); fclose ($ fp ); $ n = 1 ;...
9. PHP file replication
Introduction: This article describes how to copy files in PHP. For more information about PHP tutorials, see.
10. php get the content under the address through the webpage address php get the webpage content php get the webpage source code php open the net
Introduction: webpage address. php: php obtains the content of this address through the webpage address: Method 1 (for PHP5 and later versions): $ readcontents = fopen ("http://www.phpres.com/index.html ", "rb"); $ contents = stream_get_contents ($ readcontents); fclose ($ readcontents); echo $ contents; Method 2: echo file_get_contents ("h
[Related Q & A recommendations ]:
Php-why can't messages be returned after receiving users' images and storing them on their servers?
PHP adds content for example and replaces all content in a.txt. How can I append content to the end of a.txt.
What does this mean when I open a file and write it to a rb?
What is rb in fopen () l? What is the function of feof?
Linux-fclose (stdout), how to enable stdout again ???
The above is a detailed article about the php fclose () function. For more information, see other related articles in the first PHP community!