browolf Posted February 12, 2010 Posted February 12, 2010 Major Grrrrrrrrrrrrrrrrrrrrrrrrr After much time banging my head again the wall over why I keep getting a blank page instead of output, I've discovered php now, by default, doesn't show code errors. ironically now i'm banging my head against the wall over how to get it to show code errors. Apparently just turning display_errors on in php.ini does nothing. :-S seriously, it really annoys me when what used to be a simple is now a major headache. Good thing ppl are going to the pub after work, I really need a drink!
sonofsanta Posted February 12, 2010 Posted February 12, 2010 Let's be honest - when has a PHP error ever been any use beyond "something is wrong somewhere!" anyway? Generally being told there was an unexpected character on Line 856 means that I actually missed a semi-colon 200 lines before that
Hightower Posted February 12, 2010 Posted February 12, 2010 Let's be honest - when has a PHP error ever been any use beyond "something is wrong somewhere!" anyway? Generally being told there was an unexpected character on Line 856 means that I actually missed a semi-colon 200 lines before that I find PHP errors to be quite detailed. If it tells me there's a parse error on a certain line then it's now common sense to look the line before for a semi colon.
browolf Posted February 12, 2010 Author Posted February 12, 2010 My code always has like 20million errors so they were pretty handy, and you do get used to what the more obscure ones tend to mean. I can't code when I don't know what my errors are.
Hightower Posted February 12, 2010 Posted February 12, 2010 My code always has like 20million errors so they were pretty handy, and you do get used to what the more obscure ones tend to mean. I can't code when I don't know what my errors are. Have you set up a custom error handler? This is always the first step I take when coding anything with PHP.
mac_shinobi Posted February 12, 2010 Posted February 12, 2010 (edited) Have you set up a custom error handler? This is always the first step I take when coding anything with PHP. how do you do that ? similiar to vbscript where you do something along the lines of on error goto err: all your code goes here err: response.write error.description or something along those lines ?? Edited February 12, 2010 by mac_shinobi
Hightower Posted February 13, 2010 Posted February 13, 2010 Create a function in your script: function custom_errors($errno, $errstr){ echo " $errno: $errstr"; } Then make sure you set it within your PHP script: set_error_handler(custom_errors); This allows you to set your errors up to appear how you like. You can wrap it in CSS to make it look pretty etc... That's a very basic example. I set mine up to show if the site is not live, or show a simple error if site is live and email admin. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now