//1.初始化 $ch = curl_init(); //2.设置选项,包括URL curl_setopt($ch, CURLOPT_URL, ‘http://www.baidu.com‘); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); //3.执行并获取HTML文档内容 $output = curl_exec($ch); //4.错误判断 if ($output === FALSE){ echo ‘cURL Error:‘.curl_error($ch); } //5.返回cURL执行过程中相关信息(方便调试和查错) $info = curl_getinfo($ch); curl_close($ch); echo $output;
时间: 2024-10-05 22:54:25