PHP get_headers不工作? [英] PHP get_headers not working?

查看:91
本文介绍了PHP get_headers不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想获取网站标题,但get_headers不返回任何内容

这是我的代码


I want to get headers of website but get_headers return nothing
This is my code

<?php
$url = 'http://www.example.com';

print_r(get_headers($url));
?>

为了您的信息,我的网络托管服务提供商是网络解决方案

问题来自我的代码或来自网络托管服务提供商?
什么是获取一个网站标题的解决方案?

For your information my web hosting provider is network solution
Does the problem from my code or from the web hosting provider ?
And what's the solution to get the headers of one website ?

推荐答案

如果禁用了get_headers,那么你也可以使用cURL。

If get_headers is disabled then you can also use cURL instead.

$curl = curl_init();
curl_setopt_array($curl, array(    
    CURLOPT_URL => $url,
    CURLOPT_HEADER => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_NOBODY => true));

$header = explode("\n", curl_exec($curl));
curl_close($curl);

print_r($header);

这篇关于PHP get_headers不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆