Please note that a bug exists in Xdebug versions up to at least 2.1.2 where E_USER_DEPRECATED is not supported even in PHP 5.3.0+.
定義済み定数
以下の定数は、PHP コアに含まれており、常に利用可能です。
注意: 以下の定数をphp.iniで使用することができますが、 httpd.confのようなPHPの外部では、 代わりにビットマスク値を使用する必要があります。
| 値 | 定数 | 説明 | 注記 |
|---|---|---|---|
| 1 | E_ERROR (integer) | 重大な実行時エラー。これは、メモリ確保に関する問題のように復帰で きないエラーを示します。スクリプトの実行は中断されます。 | |
| 2 | E_WARNING (integer) | 実行時の警告 (致命的なエラーではない)。スクリプトの実行は中断さ れません。 | |
| 4 | E_PARSE (integer) | コンパイル時のパースエラー。パースエラーはパーサでのみ生成されま す。 | |
| 8 | E_NOTICE (integer) | 実行時の警告。エラーを発しうる状況に遭遇したことを示す。 ただし通常のスクリプト実行の場合にもこの警告を発することがありうる。 | |
| 16 | E_CORE_ERROR (integer) | PHPの初期始動時点での致命的なエラー。E_ERRORに 似ているがPHPのコアによって発行される点が違う。 | |
| 32 | E_CORE_WARNING (integer) | (致命的ではない)警告。PHPの初期始動時に発生する。 E_WARNINGに似ているがPHPのコアによって発行される 点が違う。 | |
| 64 | E_COMPILE_ERROR (integer) | コンパイル時の致命的なエラー。E_ERRORに 似ているがZendスクリプティングエンジンによって発行される点が違う。 | |
| 128 | E_COMPILE_WARNING (integer) | コンパイル時の警告(致命的ではない)。E_WARNINGに 似ているがZendスクリプティングエンジンによって発行される点が違う。 | |
| 256 | E_USER_ERROR (integer) | ユーザーによって発行されるエラーメッセージ。E_ERROR に似ているがPHPコード上でtrigger_error()関数を 使用した場合に発行される点が違う。 | |
| 512 | E_USER_WARNING (integer) | ユーザーによって発行される警告メッセージ。E_WARNING に似ているがPHPコード上でtrigger_error()関数を 使用した場合に発行される点が違う。 | |
| 1024 | E_USER_NOTICE (integer) | ユーザーによって発行される注意メッセージ。E_NOTICEに に似ているがPHPコード上でtrigger_error()関数を 使用した場合に発行される点が違う。 | |
| 2048 | E_STRICT (integer) | コードの相互運用性や互換性を維持するために PHP がコードの変更を提案する。 | PHP 5 より |
| 4096 | E_RECOVERABLE_ERROR (integer) | キャッチできる致命的なエラー。危険なエラーが発生したが、 エンジンが不安定な状態になるほどではないことを表す。 ユーザ定義のハンドラでエラーがキャッチされなかった場合 (set_error_handler() も参照ください) は、 E_ERROR として異常終了する。 | PHP 5.2.0 より |
| 8192 | E_DEPRECATED (integer) | 実行時の注意。これを有効にすると、 将来のバージョンで動作しなくなるコードについての警告を受け取ることができる。 | PHP 5.3.0 より |
| 16384 | E_USER_DEPRECATED (integer) | ユーザ定義の警告メッセージ。これは E_DEPRECATED と同等だが、 PHP のコード上で関数 trigger_error() によって作成されるという点が異なる。 | PHP 5.3.0 より |
| 32767 | E_ALL (integer) | サポートされる全てのエラーと警告。 PHP 5.4.0 より前のバージョンでは、E_STRICT レベルのエラーは除く。 | PHP 5.4.x では 32767、 PHP 5.3.x では 30719、 PHP 5.2.x では 6143、 それより前のバージョンでは 2047 でした。 |
上記の値(数値も論理値も)はどのエラーをレポートするかを指定する ビットマスクを組み立てる。ビット演算子 を使用して値を組み合わせたり特定のエラータイプをマスクすることができる。 php.ini では'|', '~', '!', '^' and '&'のみが解釈されることに 注意すべきである。
frozenfire at php dot net
12-Aug-2011 12:00
Andy at Azurite (co uk)
16-Apr-2011 04:15
-1 is also semantically meaningless as a bit field, and only works in 2s-complement numeric representations. On a 1s-complement system -1 would not set E_ERROR. On a sign-magnitude system -1 would set nothing at all! (see e.g. http://en.wikipedia.org/wiki/Ones%27_complement)
If you want to set all bits, ~0 is the correct way to do it.
But setting undefined bits could result in undefined behaviour and that means *absolutely anything* could happen :-)
PhpMyCoder
15-Jul-2010 03:26
Well, technically -1 will show all errors which includes any new ones included by PHP. My guess is that E_ALL will always include new error constants so I usually prefer:
<?php
error_reporting(E_ALL | E_STRICT);
?>
Reason being: With a quick glance anyone can tell you what errors are reported. -1 might be a bit more cryptic to newer programmers.
wolfrageweb.com
01-Oct-2009 03:52
-1 sets the error reporting to show all to include strict. Should only be used for development servers.
