note 61006 added to function.set-error-handler

From: Date: Mon, 23 Jan 2006 10:37:07 +0000
Subject: note 61006 added to function.set-error-handler
Groups: php.notes 
Request: Send a blank email to php-notes+get-102275@lists.php.net to get a copy of this message
Something that may not be obvious to everyone is that if you have an application with say, 10 .php pages, and you want your custom error handler to handle errors in each of them, then, you need to do a set_error_handler('my_err_handler'); or maybe set_error_handler('my_err_handler', E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE); at the top of _every_ _script_ (similar to session_start() behavior if you are using sessions) Otherwise, your errors, generated using trigger_error(), will show up in the normal way PHP shows errors - like this: Warning: None###invalid op - this bad user is attempting to study the internals by setting op = 39487 in C:\xampp\htdocs\myapp\Controller.php on line 10 A good idea if you are using sessions($_SESSION) as well, is to make a function say, start_session() or init_page() and put all functions like set_error_handler() and session_start() inside that function and call it at the top of each page. HTH, Joe ---- Server IP: 64.71.164.2 Probable Submitter: 202.159.224.152 ---- Manual Page -- http://www.php.net/manual/en/function.set-error-handler.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61006 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61006&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61006&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61006&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61006&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61006&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61006&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61006&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61006&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#102275) next »