- error_reporting: documentation ( source)
- set_error_handler: documentation ( source)
<?php
error_reporting(-1); //全てのエラーを有効にする
function my_error_handler($errno, $errstr, $errfile, $errline)
{
echo "ERROR [$errno] $errstr\n";
echo " Error on line $errline in file $errfile";
echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")\n";
echo "Aborting...\n";
/* Don't execute PHP internal error handler */
return true;
}
set_error_handler('my_error_handler');
function foo(int $v) {
echo $v;
}
// 不正な数値を渡す
foo('9999abcdedf99999999999');
// 大きすぎる数値を渡す
foo('9999999999999999999999999999');