update page now
Longhorn PHP 2026 - Call For Papers

Voting

: min(nine, five)?
(Example: nine)

The Note You're Voting On

klaussantana at gmail dot com
8 years ago
Hi everyone. I don't know if it is an old behavior of previous versions, but currently you can set exception and error handlers as private or protected methos, if, only if, you call `set_exception_handler()` or `set_error_handler()` within a context that can access the method.

Example:
    <?PHP
        $Handler = new class ()
        {
            public function __construct ()
            {
                set_error_handler([$this, 'HandleError');
                set_exception_handler([$this, 'HandleException']);
            }
            protected function HandleError ( $Code, $Message, $File = null, $Line = 0, $Context = [] )
            {
                // Handle error here.
            }
            private function HandleException ( $Exception )
            {
                // Handle exception here.
            }
        }
    ?>

NOTE: these methods must match the callbacks parameters signatures. I put

<< Back to user notes page

To Top