Fopen () is used to open local files.

Source: Internet
Author: User
Fopen () is used to open local files. & Lt ;? Php $ dir = & quot; http: // localhost/tmp_data/test.txt & quot; if (! ($ Fp = fopen ($ dir, & quot; r & quot;) {& nbsp; echo & quot; cannot be opened! & Quot; fopen () open the local file, but cannot open it.
$ Dir = "http: // localhost/tmp_data/test.txt ";
If (! ($ Fp = fopen ($ dir, "r ")))
{
Echo "cannot be opened! ";
Exit;
}
While (! Feof ($ fp ))
{
$ Line = fgetss ($ fp );
Echo $ line;
Echo "";
}
Fclose ($ fp );


?>
The code is as follows:


Warning: fopen (http: // localhost/tmp_data/test.txt) [function. fopen]: failed to open stream: connection attempts fail because the connection fails to respond correctly after a period of time or the connection host does not respond. In C: \ phpnow \ htdocs \ 1.php on line 3

Fatal error: Maximum execution time of 30 seconds exceeded in C: \ phpnow \ htdocs \ 1.php on line 3

------ Solution --------------------
Check http: // localhost/tmp_data/test.txt in the browser. is this accessible?
------ Solution --------------------
Whether allow_url_fopen is enabled
------ Solution --------------------
Phpinfo (); // take a look
Or search for php. ini
------ Solution --------------------
Try file_get_contents

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.