I am currently trying to understand the behavior of the new error handling in PHP 7. In the PHP Documentation for DivisionByZeroError, it states: DivisionByZeroError is thrown when an attempt is made to divide a number by zero. Fair enough, but it does not throw the DivisionByZeroError when the / operator is used. In this example, I would expect both
Tag: error-handling
What happens with set_error_handler() on PHP7 now that all errors are exceptions?
On PHP5 it makes a whole lot of sense having both set_exception_handler() and set_error_handler() defined. However, on PHP7 all (most?) errors are now exceptions. So, what’s the point on defining …
PHP hide fatal error message and redirect
If the following code returns a fatal error, I get a message on the page I don’t want users to see. I want to hide the fatal error message and redirect the user to another page: To hide the error message, I just added: But how do I catch and redirect a fatal error like this? Answer Basicaly, you can’t
redirecting to another page through php if error is Occurred?
i have to check weather the page is having error,if error is there i have to redirect to one default page like error.php I have tried with the following link but i cannot get the result changes in my .htaccess my errors.php code suggest me any idea,Thanks in advance.. Answer Are you working on a local server/localhost? /errors.php will refer
How to identify the query that caused the error using mysqli_multi_query?
Using a example from elsewhere on SO to better catch ‘hiding’ errors. While the code below will catch and return an error, is it possible to improve this to report for which query the error occurred? With the code below, the output is: Code being tested: Answer Here is an approach that will not only improve the quality of your
How to display php errors in a more readable format
I’ve recently switched from WAMP/XAMPP to LAMP and one thing I found useful was the clean, formatted error reporting. On my current server it just displays errors as plain text, and it can be hard to …
How do I ensure I caught all errors from MySQLi::multi_query?
The docs for multi_query say: Returns FALSE if the first statement failed. To retrieve subsequent errors from other statements you have to call mysqli_next_result() first. The docs for next_result say: Returns TRUE on success or FALSE on failure. Finally, the example posted in the docs for multi_query use the return value from next_result to determine when there are no more
php return 500 error but no error log
I am having an issue when I have a php application that is returning an internal server error (500) however nothing is showing up in the error log. Now I know there are error with what I am trying to …
PHP error_log errors to MySQL
In a previous ticket i asked about logging PHP errors in MySQL which gives me: I can make this work but only if it is triggerred like this: However, I also want the error handler to be called for all errors such as syntax errors like: But these errors are just outputted to the screen, what am i doing wrong?
Outputting all PHP errors to database not error_log
Is it possible to make all PHP errors be written to MySQL instead of to the standard error_log file. I guess this would be possible if i wrote my own error handler from scratch but i have a lot of legacy code in place and ideally i would just make 1 global change and that would be it. Can this