私の質問はこれに似ていますが、正確ではありません。
そうして、script.phpに解析エラーがある場合$string = @file_get_contents('http://www.somesite.com/script.php');
、boolfalseでは$string
なく解析エラーの値を取得します。エラーはローカルサイトではなく、リモートサイトにあります。
その場合を確認するために文字列の比較を行う必要があると思いましたが、検索する必要のある特定の文字列のリストはあり'<b>Parse error</b>:'
ます'<b>Warning</b>:'
か?リモートスクリプトのエラーをチェックするためのより良い方法はありますか?
(あなたの提案に違いが生じる場合に備えて、私は両方のドメインを管理しています。)
これが私がリモートサーバーに置いたコードです:
if(!$_SERVER['QUERY_STRING'])
{
echo('Can you get me?');
}
else
{
foreach ($imnotanarray as $fail) //intentionally cause an error
{
echo $fail;
}
}
これがローカルサーバーからのコードです
$success=file_get_contents('http://www.tecbrat.com/fgc_responder.php');
$success_header=$http_response_header[0];
$failure=file_get_contents('http://www.tecbrat.com/fgc_responder.php?do=fail');
$failure_header=$http_response_header[0];
$failure2=@file_get_contents('http://www.tecbrat.com/fgc_responder.phxp');
$failure2_header=$http_response_header[0];
echo 'Success is '.$success.'and the header is '.$success_header."<br><br>\n\n";
echo 'Failure is '.$failure.'and the header is '.$failure_header."<br><br>\n\n";
echo 'Another Failure is ';
var_dump($failure2);
echo ' and the header is '.$failure2_header;