Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

Major Grrrrrrrrrrrrrrrrrrrrrrrrr :mad:

 

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!

Posted

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 :doh:

Posted
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 :doh:

 

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.

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

Posted (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 by mac_shinobi
Posted

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.

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...