|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-12-06 09:36 UTC] lcx165 at gmail dot com
Description:
------------
When opcache.so loaded,use set_error_handler function listen all error.
When E_Deprecated happened, can't call error_handler function, use php system error display.
Test script:
---------------
//a.php
<?php
class A {
//E_Deprecated
function a() {
}
}
//error.php
<?php
error_reporting(E_ALL);
set_error_handler(function($code, $msg, $file, $line) {
echo "[{$code}] {$msg}\r\n";
});
//NOTICE
echo $a;
//E_Deprecated
include 'a.php';
//run as cli: php error.php
Expected result:
----------------
[8] Undefined variable: a
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in /root/a.php on line 3
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in /root/a.php on line 3
Actual result:
--------------
[8] Undefined variable: a
[8192] Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 10:00:01 2025 UTC |
Tested this in php 8.2.1 with the code below: jochem.php ----------- error_reporting(E_ALL); ini_set('display_errors', 1); //header('Content-type: text/plain; charset=windows-1252'); header('Content-type: text/plain; charset=utf-8'); function shutdown() { $error = error_get_last(); if ($error) { echo "\n\n--------------- SHUTDOWN ---------------------\n\n"; var_dump($error); echo "\n--------------- EO: SHUTDOWN ---------------------\n\n"; } } register_shutdown_function('shutdown'); function myErrorHandler($errno, $errstr, $errfile, $errline) { echo "\n\n--------------- ERROR ---------------------\n\n"; var_dump(error_reporting()); echo "\n" . 'errno = '; print_r($errno); echo "\n" . 'errstr = '; print_r($errstr); echo "\n" . 'errfile = '; print_r($errfile); echo "\n" . 'errline = '; print_r($errline); echo "\n--------------- EO: ERROR ---------------------\n\n"; // die(); return true; // return false; } set_error_handler("myErrorHandler"); function exception_handler($exception) { echo "\n\n--------------- EXCEPTION ---------------------\n\n"; echo "class: ", get_class($exception), "\n"; echo "message: ", $exception->getMessage(), "\n"; echo "regel: ", $exception->getLine(), "\n"; echo "\n--------------- EO: EXCEPTION ---------------------\n\n"; } set_exception_handler('exception_handler'); require 'jochem2.php'; echo "\nEOF"; ----------- jochem2.php ----------- <?php class A { final private function iets() { } } $a2 =new A(); -----------