Ec (2); * I have a question requesting the url from the php tutorial code. I need to call a service to use a query string from my php code. If I type a URL in my browser, it still works, but if I use the file to get the URL and the content () to make a call, I get: & nbsp; copy the code $ queryfile_get_contents (www.111cn.net), ec script ec (2), and script
/*
I have a question about the url of the php tutorial code. I need to call a service to use a query string from my php code. If I type a URL in my browser, it still works, but if I use the file to get the URL and the content () to call, I get:
| The Code is as follows: |
|
$ Query = file_get_contents ('HTTP: // www.111cn.net '); Echo ($ query ); |
There are three possible problems
1. Is the allow_url_fopen option of php. ini open? If it is off, it cannot be accessed. Change it to on.
Ii. php. ini enabled the Security Mode
3. The machine is installed with strong fire prevention
Other solutions
*/
| The Code is as follows: |
|
$ Curl_handle = curl_init (); Curl_setopt ($ curl_handle, curlopt_url, 'HTTP: // www.111cn.net '); Curl_setopt ($ curl_handle, curlopt_connecttimeout, 2 ); Curl_setopt ($ curl_handle, curlopt_returntransfer, 1 ); Curl_setopt ($ curl_handle, curlopt_useragent, 'Your application name '); $ Query = curl_exec ($ curl_handle ); Curl_close ($ curl_handle ); |