Skip to content

Instantly share code, notes, and snippets.

@macintoshplus
Last active January 10, 2018 21:44
Show Gist options
  • Save macintoshplus/522cd55fb7c27511ce94207ce9ab767d to your computer and use it in GitHub Desktop.
Save macintoshplus/522cd55fb7c27511ce94207ce9ab767d to your computer and use it in GitHub Desktop.
Strange work for PHP 7+ for error_reporting reading
/Users/jb/Sites/testErrorHandler/index.php:5:int 0
/Users/jb/Sites/testErrorHandler/index.php:5:string '32767' (length=5)
/Users/jb/Sites/testErrorHandler/index.php:5:int 0
/Users/jb/Sites/testErrorHandler/index.php:5:string 'deprecated' (length=10)
/Users/jb/Sites/testErrorHandler/index.php:5:int 0
/Users/jb/Sites/testErrorHandler/index.php:5:string '32767' (length=5)
/Users/jb/Sites/testErrorHandler/index.php:5:int 0
/Users/jb/Sites/testErrorHandler/index.php:5:string 'user warning' (length=12)
/Users/jb/Sites/testErrorHandler/index.php:12:string '7.0.23' (length=6)
This is due to the @ before the trigger_error function name.
<?php
error_reporting(E_ALL);
set_error_handler(function ( int $errno , string $errstr , string $errfile , int $errline , array $errcontext) {
var_dump(error_reporting(), ini_get('error_reporting'), error_reporting() & $errno, $errstr);
}, E_ALL);
@trigger_error('deprecated', E_USER_DEPRECATED);
@trigger_error('user warning', E_USER_NOTICE);
var_dump(PHP_VERSION);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment