How to show a error page when there is a php mistake? |
[eluser]chefnelone[/eluser]
hello, When I make a php mistake, let's say I forget to close a braket ')' o to put a semicolon ';' I get a blank page. Is there a way to show a customized error page?
[eluser]Jelmer[/eluser]
Check out UhOh from Dan Horrigan. And just to get errors to show in CI without modification change the error_reporting at the top of the main index.php file: Code: error_reporting( E_ALL ); Just don't forget to turn errors off and set error_reporting(0) once your site goes live.
[eluser]chefnelone[/eluser]
[quote author="Jelmer" date="1280262293"]Check out UhOh from Dan Horrigan. And just to get errors to show in CI without modification change the error_reporting at the top of the main index.php file: Code: error_reporting( E_ALL ); Just don't forget to turn errors off and set error_reporting(0) once your site goes live.[/quote] That's brillant. But now I can't disable it. I set error_reporting(0) in the top of the main index.php file. But where is the line?: ini_set('display_errors', 'On');
[eluser]Jelmer[/eluser]
It's not in there because not all configurations of PHP allow it. Just add it. And turning UhOh off can be a problem. I added a config option myself with my IP and only show the extensive errors when I'm the one requesting it and modified the class to show a general error when the request was made by someone else. I can't just post the code because I did it in my own CI fork (AugmentedCI in my sig) and merged the CI_Exception class with UhOh. But you can see what I did on BitBucket on lines 76 and 370.
[eluser]chefnelone[/eluser]
[quote author="Jelmer" date="1280266004"]It's not in there because not all configurations of PHP allow it. Just add it. And turning UhOh off can be a problem. I added a config option myself with my IP and only show the extensive errors when I'm the one requesting it and modified the class to show a general error when the request was made by someone else. I can't just post the code because I did it in my own CI fork (AugmentedCI in my sig) and merged the CI_Exception class with UhOh. But you can see what I did on BitBucket on lines 76 and 370.[/quote] uhoh I think this is a little advanced for my knowledge. Thanks anyway
[eluser]Jelmer[/eluser]
An easier way is to use UhOh only in production and just switch off hooks and delete the MY_Exceptions.php file when your site goes live.
[eluser]chefnelone[/eluser]
Even though UhOh is very useful and I already integrated to my ci app. What I was looking for is something to use when the site goes Live so that if I made a php mistake it can show a customized error page, something like "We are doing some maintenance, come back later" which is much better than a blank page. thanks |
Welcome Guest, Not a member yet? Register Sign In |