I am confused about the file_get_contents () function. I want to try a remote call today, but I am very depressed. & nbsp; I used file_get_contents to get a template file & nbsp; & nbsp; then modify the template again $ moban & nbsp ;=& nbs about the file_get_contents () function.
I want to try a remote call today, but I am very depressed.
I used file_get_contents to obtain a template file.
Modify the template again.
$ Moban = file_get_contents ('http: // 127.0.0.1/2.html ');
$ Htmlcontent = str_replace ('{content1}', $ contentreplace, $ moban );
$ Htmlname = "1.html ";
File_put_contents ($ htmlname, $ htmlcontent );
You can understand it all.
However, there is a problem. The 1.html generated by me is blank, but it can be seen in the source code.
Ps: It's okay when the handler calls that 1.html. That is
$ Moban Upload file('2.html ');
$ Htmlcontent = str_replace ('1', $ contentreplace, $ moban );
$ Htmlname = "1.html ";
File_put_contents ($ htmlname, $ htmlcontent );
In this way, the page is displayed normally.
Why?
------ Solution --------------------
Try file_get_contents ("http: // localhost/2.html ");
In addition, are you using port 80?
Telnet localhost 80.
If not, add the port number.
------ Solution --------------------
You have never
$ Moban = file_get_contents ('http: // 127.0.0.1/2.html ');
Echo $ moban;
$ Htmlcontent = str_replace ('{content1}', $ contentreplace, $ moban );
Echo'
----------
'. $ Htmlcontent;
------ Solution --------------------
If
Echo $ moban;
When the volume is empty, you need to use other methods to retrieve it, such as the curl
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