![]() |
Best Practice for Error handling - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: Best Practice for Error handling (/showthread.php?tid=64900) |
Best Practice for Error handling - ardavan - 04-09-2016 Hey, I wonder how to avoid "A PHP Error was encountered" when user enter class/method manually to the url ? actually i want to learn how can handle the errors and show the nice page to the users Also avoid to display my directory to the hackers ![]() In my index.php file I've added Code: define('ENVIRONMENT', 'production'); Thanks for your time and helps guys Have a good day ![]() RE: Best Practice for Error handling - PaulD - 04-09-2016 Hi, If someone tries to mess with the url you should get a 404 error page, which you can format in the errors/html folder in the view files. Alternatively, if they mess with some of the values in your method, your method should be checking that, and posting an error page appropriately. Hope that helps, Paul. RE: Best Practice for Error handling - ardavan - 04-09-2016 (04-09-2016, 03:39 PM)PaulD Wrote: Hi, Hey Paul, i know about the 404 error page which is in the view folder. but i wanna know how to set if someone input some class/method in my url. Currently, for example, if you put something out of my classes or methods the page will redirect to 404 page . but if you input the correct class/method will show you this I've added Code: http://example.com/index.php/early_access/provider'- and I've got this page(which is i don't wanna see this) Code: A PHP Error was encountered i would like to change this page to 404 or redirect to homepage or whatever just i don't like to give them my application directory! Thanks RE: Best Practice for Error handling - PaulD - 04-10-2016 Hi, Not sure how it is possible to have an error in your php for the error_general.php, since it just echos the title and the message. Have you changed it, trying to use server headers to identify the source and redirect? Personally I would not try to avoid the error pages as this can lead to more confusion that it solves, but they are in the view files specifically so you can format them however you want. The php error you are getting above is something you need to locate and fix. You should never be able to submit a url to one of your functions that can cause a php error, your own error checking should take care of that. The error pages themselves, I have never experienced them throwing an error like that, so I presume you have customized them in some way. Sorry I cannot be of more help, Paul. |