Php class call external class


I have a php page that calls and runs a method called pagestart() in a class called construct. Later in that same page I call a different method in a different class. If that different method errors for any reason I would like to have it call the error() function in the construct class.

My question is is there a way to call the error() method without doing:

$construct = new construct;

And just tell the function to look in the class included by the main php file?


Best Solution

You could call set_error_handler at the start of that function and restore_error_handler at the end of it.