CodeIgniter Forums
How to show a error page when there is a php mistake? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: How to show a error page when there is a php mistake? (/showthread.php?tid=32568)



How to show a error page when there is a php mistake? - El Forum - 07-27-2010

[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?


How to show a error page when there is a php mistake? - El Forum - 07-27-2010

[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 );
ini_set('display_errors', 'On');

Just don't forget to turn errors off and set error_reporting(0) once your site goes live.


How to show a error page when there is a php mistake? - El Forum - 07-27-2010

[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 );
ini_set('display_errors', 'On');

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');


How to show a error page when there is a php mistake? - El Forum - 07-27-2010

[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.


How to show a error page when there is a php mistake? - El Forum - 07-27-2010

[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


How to show a error page when there is a php mistake? - El Forum - 07-27-2010

[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.


How to show a error page when there is a php mistake? - El Forum - 07-27-2010

[eluser]chefnelone[/eluser]
you right, i'll do that. Thanks jel


How to show a error page when there is a php mistake? - El Forum - 07-27-2010

[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