get_headers获取不到http状态码解决方法

1 $url = 'https://www.cnblogs.com';
2 $ch = curl_init($url);
3 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0");
4 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
5 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
6 curl_exec($ch);
7 $info = curl_getinfo($ch);
8 curl_close($ch);
9 var_dump($info);

完美解决了Nginx不支持get_headers函数。

posted @ 2023-05-16 11:11  安语未  阅读(17)  评论(0编辑  收藏  举报