私のシーンは:
ユーザーは、特定の (クライアント) URL が宛先 URL に存在するかどうかを確認したいので、1 つの宛先 URL で特定の URL をテストする簡単なスクリプトを作成しました。
ここに私のphpスクリプトがあります:
if(isset($_POST['check_url']))
{
$client_url = $_POST['client_url'];
$destination_url = $_POST['destination_url'];
$contents = file_get_contents($destination_url);
$search = $client_url;
if(strpos($contents,$search)== FALSE)
{
echo "Not Found";
}
else
{
echo "Found";
}
}
これが私のhtmlスクリプトです:
<form method="post" action="test.php">
<label>Client URL:</label>
<input type="text" value="" name="client_url" /><br />
<label>Destination URL:</label>
<textarea value="" name="destination_url" ></textarea><br />
<button type="submit" name="check_url">Check</button>
</form>
上記のスクリプトは、単一の宛先 URL の場合に機能しますが、(配列に変換して) 複数の宛先 URL を投稿しようとすると、エラーが発生します:
Warning: file_get_contents( http://learntk12.org/story.php?title=seo-link-building-service) [function.file-get-contents]: failed to open stream: No such file or directory in "path to source file" on line 24
24行目は次のとおりです。$contents[$i] = file_get_contents($arr[$i]);
配列を使用した私のphpコードは次のとおりです。
if(isset($_POST['check_url']))
{
$client_url = $_POST['client_url'];
$destination_url = $_POST['destination_url'];
$destination =str_replace("\r",",",$destination_url);
$arr = explode(",",$destination);
$search = $client_url;
for($i=0;$i<count($arr);$i++)
{
$contents[$i] = file_get_contents($arr[$i]);
if (strpos($contents[$i], $search) === FALSE)
{
echo "Not Found";
}
else
{
echo "Found";
}
}
}
このスクリプトのどこで遅れていますか?