我尝试在PHP编码中使用http_get进行跨域请求。但是,在我的服务器上,没有安装所需的模块。我不知道要安装什么才能使http_get操作变为可能。
我收到了以下错误:
致命错误: 在 C:\xampp\htdocs\article\index.php 的第2行调用未定义函数http_get()
我尝试使用PECL pecl_http >= 0.1.0进行如下操作:
http_get — 执行GET请求
但是,我没有找到解决方案。
因此,请帮助我运行http_get编码。谢谢!
我尝试在PHP编码中使用http_get进行跨域请求。但是,在我的服务器上,没有安装所需的模块。我不知道要安装什么才能使http_get操作变为可能。
我收到了以下错误:
致命错误: 在 C:\xampp\htdocs\article\index.php 的第2行调用未定义函数http_get()
我尝试使用PECL pecl_http >= 0.1.0进行如下操作:
http_get — 执行GET请求
但是,我没有找到解决方案。
因此,请帮助我运行http_get编码。谢谢!
我认为您需要在php.ini
文件中启用extension=php_http.dll
,然后重新启动Apache服务器。
我建议您使用cURL而不是http_get()
(操作相同,您需要启用extension=php_curl.dll
并重新启动Apache)
希望能有所帮助 :)
php.ini
中启用extension=php_http.dll
并重新启动apache,但现在绝对没有必要使用http_get()
。Curl
用法:// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://testcURL.com/?item1=value&item2=value2',
CURLOPT_USERAGENT => 'User Agent X'
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
file_get_content()
的用法:
$my_var = file_get_contents("https://site/");
copy()
的使用方法:
copy("https://site/image.png", "/local/image.png");
http_get()
仍未定义。 - n8bar