Php class call external class

classfunctionincludemethodsphp

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:

include_once("class/construct.class.php");
$construct = new construct;
$construct->error($msg);

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

Thanks.

Best Solution

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