gpt4 book ai didi

PHP 获取 header 不适用于 -

转载 作者:可可西里 更新时间:2023-11-01 00:05:55 25 4
gpt4 key购买 nike

我正在尝试获取 URL header 的输出,它非常适合子域示例

subdomain.example.com

我会收到正常消息 HTTP 200 ok 等,但如果子域中有 -, header 中不会显示任何内容。

-test.tumblr.comtest-.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,并且能够获取 header 。

$url = 'http://test-.myserver.loc';
print_r(get_headers($url))

http://us3.php.net/get_headers

关于PHP 获取 header 不适用于 -,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14472490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com