gpt4 book ai didi

php - 如何在php中检查url是否存在

转载 作者:行者123 更新时间:2023-12-03 23:22:18 25 4
gpt4 key购买 nike

我想检查网址http://example.com/file.txt 在 php 中存在与否。我该怎么做?

最佳答案

if(! @ file_get_contents('http://www.domain.com/file.txt')){
echo 'path doesn't exist';
}

这是最简单的方法。如果您不熟悉 @ ,这将指示函数返回 false 如果它否则会抛出错误

关于php - 如何在php中检查url是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13226417/

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