我正在尝试获取URL标头的输出,它与子域示例配合得很好
subdomain.example.com
我会得到正常的消息 HTTP 200 ok 等,但如果子域中有-
,则标头中不会显示任何内容。
-test.tumblr.com
或test-.tumblr.com
有没有更好的方法?我的示例代码如下。
$url = "http://-test.tumblr.com";
$url_headers = @get_headers($url);
$urlheader = $url_headers[0];
echo $urlheader;
如果无法通过检查标题来完成,我将如何查看该页面是否存在。我试过使用 curl,但它做同样的事情。
谢谢
当您取消取消禁止来自get_headers的警告时,您是否会收到只能在 url 上使用get_headers的警告?
Warning: get_headers(): This function may only be used against URLs
尝试在子域前面添加 http://。我在主机文件中添加了一个子域test-.myserver.loc,并能够获取标头。
$url = 'http://test-.myserver.loc';
print_r(get_headers($url))
http://us3.php.net/get_headers