接続が中止されたときにセッションで値をマークしようとしましたが、php関数connection_status()が正しく機能しません!以下のコードは次のとおりです。
1 whileステートメントなし:
session_start();
ignore_user_abort(true);
ob_end_clean();
echo 'Testing'; //test if it has output to the browser
flush();
sleep(7);
echo "test";
flush();
if (connection_status() != CONNECTION_NORMAL){
$_SESSION['conn']='failed'; //never called
}
2 WITH whileステートメント:
session_start();
ignore_user_abort(true);
ob_end_clean();
echo "Testing connection handling";
while (1) {
if (connection_status() != CONNECTION_NORMAL){
$_SESSION['conn']='failed'; //worked at some time
break;
}
sleep(1);
echo "test";
flush();
}
これらのコードでテストするとき、コードの実行が終了する前に手動で接続を中止しました。しかし、最初のコードは私が機能しないので機能しませんm excepted(do not mark assign 'failed' to the session) , and the second code works.
Why the first dosen
か?!