RE: [PHP]How to handle E_ERROR,E_PARSE with a user defined function
-Original Message- From: Yuchen Wang [mailto:phob...@gmail.com] Sent: Tuesday, May 22, 2012 10:19 PM To: php-general Maillist Subject: [PHP]How to handle E_ERROR,E_PARSE with a user defined function Hi all, How to handle E_ERROR,E_PARSE with a user defined function ? Aren't these startup errors? I am not quite sure, but if the y can't be handled with php. This is from the PHP docs The following error types cannot be handled with a user defined function: E_ERROR , E_PARSE , E_CORE_ERROR , E_CORE_WARNING , E_COMPILE_ERROR , E_COMPILE_WARNING , and most of E_STRICT raised in the file where set_error_handler() is called. If errors occur before the script is executed (e.g. on file uploads) the custom error handler cannot be called since it is not registered at that time. So the only thing you can do is have a watchdog on your phperror.log and dosomething if these errors occur. To preparse syntax errors you can use find and php -l $ find . -name *.php -exec php -l {} \; No syntax errors detected in ./bootstrap.php No syntax errors detected in ./htdocs/index.php No syntax errors detected in ./templates/comment.php No syntax errors detected in ./templates/postform.php No syntax errors detected in ./templates/blog.php No syntax errors detected in ./templates/main.php No syntax errors detected in ./templates/error.php No syntax errors detected in ./templates/commentform.php No syntax errors detected in ./templates/post.php No syntax errors detected in ./classes/rendering/View.php No syntax errors detected in ./classes/storage/SqliteStorage.php No syntax errors detected in ./classes/storage/Storage.php No syntax errors detected in ./classes/models/Blog.php No syntax errors detected in ./classes/models/Comment.php No syntax errors detected in ./classes/models/Post.php No syntax errors detected in ./classes/models/Model.php No syntax errors detected in ./classes/helper/HTMLResult.php No syntax errors detected in ./classes/helper/Result.php No syntax errors detected in ./classes/helper/ApplicationConfig.php No syntax errors detected in ./classes/helper/ErrorHandler.php No syntax errors detected in ./classes/helper/Request.php No syntax errors detected in ./classes/helper/ExceptionHandler.php No syntax errors detected in ./classes/helper/JSONResult.php No syntax errors detected in ./classes/app/Router.php No syntax errors detected in ./classes/controller/BlogController.php No syntax errors detected in ./classes/controller/Controller.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]How to handle E_ERROR,E_PARSE with a user defined function
Thank you I finally found a method to process these errors that using register_shutdown_function() You can read it from this http://insomanic.me.uk/post/229851073 or http://mo47.com/blog/2012/catching-fatal-errors 2012/5/23 ma...@behnke.biz ma...@behnke.biz -Original Message- From: Yuchen Wang [mailto:phob...@gmail.com] Sent: Tuesday, May 22, 2012 10:19 PM To: php-general Maillist Subject: [PHP]How to handle E_ERROR,E_PARSE with a user defined function Hi all, How to handle E_ERROR,E_PARSE with a user defined function ? Aren't these startup errors? I am not quite sure, but if the y can't be handled with php. This is from the PHP docs The following error types cannot be handled with a user defined function: E_ERROR , E_PARSE , E_CORE_ERROR , E_CORE_WARNING , E_COMPILE_ERROR , E_COMPILE_WARNING , and most of E_STRICT raised in the file where set_error_handler() is called. If errors occur before the script is executed (e.g. on file uploads) the custom error handler cannot be called since it is not registered at that time. So the only thing you can do is have a watchdog on your phperror.log and dosomething if these errors occur. To preparse syntax errors you can use find and php -l $ find . -name *.php -exec php -l {} \; No syntax errors detected in ./bootstrap.php No syntax errors detected in ./htdocs/index.php No syntax errors detected in ./templates/comment.php No syntax errors detected in ./templates/postform.php No syntax errors detected in ./templates/blog.php No syntax errors detected in ./templates/main.php No syntax errors detected in ./templates/error.php No syntax errors detected in ./templates/commentform.php No syntax errors detected in ./templates/post.php No syntax errors detected in ./classes/rendering/View.php No syntax errors detected in ./classes/storage/SqliteStorage.php No syntax errors detected in ./classes/storage/Storage.php No syntax errors detected in ./classes/models/Blog.php No syntax errors detected in ./classes/models/Comment.php No syntax errors detected in ./classes/models/Post.php No syntax errors detected in ./classes/models/Model.php No syntax errors detected in ./classes/helper/HTMLResult.php No syntax errors detected in ./classes/helper/Result.php No syntax errors detected in ./classes/helper/ApplicationConfig.php No syntax errors detected in ./classes/helper/ErrorHandler.php No syntax errors detected in ./classes/helper/Request.php No syntax errors detected in ./classes/helper/ExceptionHandler.php No syntax errors detected in ./classes/helper/JSONResult.php No syntax errors detected in ./classes/app/Router.php No syntax errors detected in ./classes/controller/BlogController.php No syntax errors detected in ./classes/controller/Controller.php -- *Yuchen Wang*
RE: [PHP]How to handle E_ERROR,E_PARSE with a user defined function
-Original Message- From: Yuchen Wang [mailto:phob...@gmail.com] Sent: Tuesday, May 22, 2012 10:19 PM To: php-general Maillist Subject: [PHP]How to handle E_ERROR,E_PARSE with a user defined function Hi all, How to handle E_ERROR,E_PARSE with a user defined function ? -- *Yuchen Wang* I suggest you try http://www.php.net/set_error_handler -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php