我有一个脚本,它需要一个some.txt文件并读取链接并返回,如果我的网站反向链接是否存在。但问题是,速度很慢,我想提高速度。有什么方法可以提高速度吗?提高我的脚本的速度
<?php
ini_set('max_execution_time', 3000);
$source = file_get_contents("your-backlinks.txt");
$needle = "http://www.submitage.com"; //without http as I have imploded the http later in the script
$new = explode("\n",$source);
foreach ($new as $check) {
$a = file_get_contents(trim($check));
if (strpos($a,$needle)) {
$found[] = $check;
} else {
$notfound[] = $check;
}
}
echo "Matches that were found: \n ".implode("\n",$found)."\n";
echo "Matches that were not found \n". implode("\n",$notfound);
?>
不,它取决于网络,你无法控制。 –
@ N.B。是正确的。最大的问题将是网络,但使用strpos可能是另一种解决方案。您可以简单地在返回的内容中检查您的域名的位置,而不是分割整个字符串。你可能需要做一些调查,但值得一试? – Gavin
您应该使用异步HTTP。但是,我无法找到如何在PHP中执行此操作的好源代码。 –