views:

527

answers:

1

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.

+3  A: 

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

Ant P.