In my class constructor, I have the following:
set_error_handler(array(
$this,
'_custom_error_handler'
));
In the same class, I have the following method defined:
protected function _custom_error_handler($error_number, $error_string, $error_file, $error_line)
When something in my code runs into an error, I get the following warning:
Warning: Invalid callback ... _custom_error_handler, cannot access protected method
Why can't this class (or its children?) access this protected method? Shouldn't a protected method be accessible???
A protected method is only accessible from inside the class, or subclasses.
In this case set_error_handler is calling a method, and set_error_handler is outside your class. Therefore it must be public.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With