试试这个。请注意,您可能必须跳过行尾,因此请使用 rtim()。此外,如果您希望 urls.txt 针对多个输入 url 进行测试,该脚本也将完成该操作。
<?php
$site = "http://site.com"
$urls = file('urls.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach($urls as $url) {
//if you want to test multiple input urls, they might be in input array, say url[]
//we can check for the array here
if(is_array($_POST['url'])) {
foreach($_POST['url'] as $post_url) {
//You may want to skip line endings, so use rtrim
if($post_url == ($site . rtrim($url)) {
print 'Url found - '.$post_url.'<br>';
} else {
print 'Url not found - '.$post_url.'<br>';
}
}
} else {
//You may want to skip line endings, so use rtrim
if($POST['url'] == ($site . rtrim($url)) {
print 'Url found - '.$POST['url'].'<br>';
} else {
print 'Url not found - '.$POST['url'].'<br>';
}
}
}
?>