Fopen () is used to open local files. & Lt ;? Php?dir"=localhosttmp_datatest.txt & quot; if (! ($ Fpfopen ($ dir, & quot; r & quot;) {& nbsp; echo & quot; cannot be opened! & Quot; & nbsp; exit ;}& nbsp; while fopen () open the local file, and the old file cannot be opened.
$ 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