Php 致命错误:调用未定义的函数http_get()
我尝试使用http\U get在php编码中进行跨域请求。在我的服务器中,没有安装所需的模块。我不知道要安装什么才能使http\U get成为可能 我犯的错误是 致命错误:在中调用未定义的函数http_get() 第2行的C:\xampp\htdocs\article\index.php 我试图这样做(PECL PECL_http>=0.1.0) http_get-执行get请求 但是,我没有找到解决办法Php 致命错误:调用未定义的函数http_get(),php,cross-domain,Php,Cross Domain,我尝试使用http\U get在php编码中进行跨域请求。在我的服务器中,没有安装所需的模块。我不知道要安装什么才能使http\U get成为可能 我犯的错误是 致命错误:在中调用未定义的函数http_get() 第2行的C:\xampp\htdocs\article\index.php 我试图这样做(PECL PECL_http>=0.1.0) http_get-执行get请求 但是,我没有找到解决办法 所以,请帮我运行http_-get编码。提前感谢。我认为您必须在php.ini文件中启用e
所以,请帮我运行http_-get编码。提前感谢。我认为您必须在
php.ini
文件中启用extension=php\u http.dll
,然后重新启动Apache服务器。我建议您使用cURL而不是
http\u get()
(同样的操作,您必须启用extension=php\u cURL.dll
并重新启动apache)希望这有帮助:)要直接回答这个问题,您必须在
php.ini
中启用extension=php\u http.dll
并重新启动apache,但在我们的时代绝对不需要使用http\u get()
以下是3个不错的选择:
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\u get\u content()
用法:
$my_var = file_get_contents("https://site/");
copy("https://site/image.png", "/local/image.png");
copy()
用法:
$my_var = file_get_contents("https://site/");
copy("https://site/image.png", "/local/image.png");
出于好奇,你为什么建议他们改用cURL?@Halayem你能举一个cURL的用法例子吗<代码>http_get()仍未定义。