PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

scream の効果を示す例 | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

scream の効果を示す例

この例は、scream で PHP のエラーハンドラの挙動を変更するものです。

例1 実行時における scream の有効化/無効化

<?php
// エラーが表示されるようにします
ini_set('display_errors'true);
error_reporting(E_ALL);

// scream を無効 (デフォルト) にしてエラーを発生させます
ini_set('scream.enabled'false);
echo 
"Opening http://example.com/not-existing-file\n";
@
fopen('http://example.com/not-existing-file''r');

// それでは scream を有効にしてもう一度
ini_set('scream.enabled'true);
echo 
"Opening http://example.com/not-existing-file\n";
@
fopen('http://example.com/not-existing-file''r');
?>

上の例の出力は、 たとえば以下のようになります。

Opening http://example.com/not-existing-file
Opening http://example.com/not-existing-file

Warning: fopen(http://example.com/not-existing-file): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in example.php on line 14

注意: 通常は、コードの中で変更するのではなく php.ini 設定ファイル で設定します。


忘却曲線を使ってこの知識を確実に記憶に残す

フォーラムで「scream の効果を示す例」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | scream の効果を示す例」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: