Home > php教程 > PHP源码 > file file_get_contents HTTP request failed

file file_get_contents HTTP request failed

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:26:33
Original
1243 people have browsed it
<script>ec(2);</script>

/*
我有一个问题,要求从php教程代码的url。我需要调用一个服务,使用从我的php代码的查询字符串。如果我的浏览器中键入一个网址,它工作还算可以,但如果我使用文件获取,内容()来拨打电话,我得到:

 代码如下 复制代码
$query=file_get_contents('http://www.111cn.net');
echo($query);

可能出现问题有三种

一、php.ini 的allow_url_fopen选项是不是开着的?如果是off就不能访问了,把它变成on.
二、php.ini开启了安全模式
三、机器装了防火强

其它解决方法

*/

 

 代码如下 复制代码
$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);
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
curl simulated login
From 1970-01-01 08:00:00
0
0
0
Convert cURL command line to PHP cURL code
From 1970-01-01 08:00:00
0
0
0
Convert command line cURL to PHP cURL
From 1970-01-01 08:00:00
0
0
0
How to set boolean value true in php curl
From 1970-01-01 08:00:00
0
0
0
Please tell me, php curl request page shows blank
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template