tags:

views:

31

answers:

3

I'd like to use set_error_handler() to handle all PHP errors in one place, but I'm afraid that this is something I can't use with cheap webspace hosters. Or must I not worry much about that?

+1  A: 

set_error_handler() is part of the core PHP error handling functions, so it should work on any host.

There isn't a way to disable it that I know of, although setting the error_reporting level to 0 would make it so the handler was never called. This is something you have complete control over however.

zombat
I suppose it could be disabled with the disable_functions (see http://www.php.net/manual/en/ini.core.php#ini.disable-functions ) directive ; but I don't see why it would be disabled...
Pascal MARTIN
@Pascal - I just commented on Gumbo's answer about that, very interesting directive! I've never seen it used before.
zombat
I've seen it used for functions such as popen and fsockopen (The hosting company we use at work disables those, and a couple of others, by default)
Pascal MARTIN
+1  A: 

set_error_handler is just a normal function of PHP -- so it should work on any hosting service.

I really don't see any reason that would justify for a hosting service to disable that function -- and I've never seen it disabled.

Pascal MARTIN
+2  A: 

PHP allows to disable functions with the disable_functions directive. But I don’t see any reason for why anyone would not allow set_error_handler.

Gumbo
Interesting. I've never encountered that before, but then again, I usually build my own servers, so I guess it's something I don't really need.
zombat