我收到以下错误"警告:file_get_contents无法打开流:HTTP请求失败!HTTP/1.0 400错误请求",同时点击"http://Google.com"
<?php
$content = file_get_contents("http://www.google.com");
if (strpos($http_response_header[0], "200")) {
echo "SUCCESS";
}
else {
echo "FAILED";
}
?>
Run Code Online (Sandbox Code Playgroud)
因为这个问题,我无法解析URL.我正在使用WAMP(Apache Version-2.2.22,PHP 5.4.3版).
采取的步骤: - 1.allow_url_fopen在php.ini中启用2.Tried编码URL 3.Even Used Curl php函数遇到同样的问题.4.允许防火墙
请帮忙.
$html = @file_get_html($url);
if($html==FALSE) {
echo 'error';
} else {
echo 'success';
}
Run Code Online (Sandbox Code Playgroud)
在这里检查一下这个$ url是www.google.com.然后你得到正确的结果