PHP Errors and Warnings list
Moderator: General Moderators
PHP Errors and Warnings list
Does anyone have or know where I can find a list of the warnings and errors that a default PHP installation could possible spit out at run-time?
I'm trying to create some regexp that matches all errors, but there are a few different formats, for example:
- Syntax errors... Parse error: syntax error, unexpected [T_STRING|END|T_VARIABLE|T_NUM_STRING|etc...] in ...
- syntax error, unexpected '['
- expecting ',' or ';'
- "Using $this when not in object context in foo.php on line ..."
- "failed to open stream: No such file or directory in foo.php on line ..."
- "Fatal error: Function name must be a string in foo.php on line ..."
These are just a few off the top of my head. As you can see, there are a fair few different formats so creating some regexp could be quite difficult. Any suggestions?
I'm trying to create some regexp that matches all errors, but there are a few different formats, for example:
- Syntax errors... Parse error: syntax error, unexpected [T_STRING|END|T_VARIABLE|T_NUM_STRING|etc...] in ...
- syntax error, unexpected '['
- expecting ',' or ';'
- "Using $this when not in object context in foo.php on line ..."
- "failed to open stream: No such file or directory in foo.php on line ..."
- "Fatal error: Function name must be a string in foo.php on line ..."
These are just a few off the top of my head. As you can see, there are a fair few different formats so creating some regexp could be quite difficult. Any suggestions?
Re: PHP Errors and Warnings list
No, you haven't understood the problem properly.
I'm trying to scan an external page for PHP errors and warnings. In order to do that I need some regexp that will match to all of the errors and warnings that PHP may produce. The problem is there is no set format.
I have:
at the moment, but that doesn't match everything, only syntax errors and the like.
I'm trying to scan an external page for PHP errors and warnings. In order to do that I need some regexp that will match to all of the errors and warnings that PHP may produce. The problem is there is no set format.
I have:
Code: Select all
"(error</b>:)(.+) in <b>(.+)</b> on line <b>(.+)</b>"- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: PHP Errors and Warnings list
This might help...
http://php.net/set_error_handler
http://php.net/set_error_handler
Re: PHP Errors and Warnings list
Unfortunately not. I'm trying to find errors and warnings being displayed on a page, not necessarily a page running on my server. I need to scan a string looking for these errors, not catch them on my server 
Re: PHP Errors and Warnings list
Hi MikeMike,
Let's see... if I were to do this, I think the first thing I'd do is fetch the page you want to scan, and do a striptags() on it. This will reduce it to text. Then, let's find some things you're unlikely to find if it's not an error.
"[space]in[space][characters with no spaces].php" seems that it would match almost all errors. I actually can't think of much else that would possibly match, and I think that particular language is used in almost any error.
Now, all we need to do is find other errors, and find a special pattern that would match them! If I think of any others, I'll try to remember to come back here and post a string.
Let's see... if I were to do this, I think the first thing I'd do is fetch the page you want to scan, and do a striptags() on it. This will reduce it to text. Then, let's find some things you're unlikely to find if it's not an error.
"[space]in[space][characters with no spaces].php" seems that it would match almost all errors. I actually can't think of much else that would possibly match, and I think that particular language is used in almost any error.
Now, all we need to do is find other errors, and find a special pattern that would match them! If I think of any others, I'll try to remember to come back here and post a string.
Re: PHP Errors and Warnings list
Well this is what I have at the moment:
Code: Select all
eregi("(error|warning)</b>:(.+) in <b>(.+)</b> on line <b>(.+)</b>", $page)Re: PHP Errors and Warnings list
OMG.
I understand your Regex.
I think I'm losing my mind.
BTW, wouldn't this work just as well, but perhaps not miss things that don't use HTML?
Edit: Cool! That's how you make it do PHP syntax highlighting!
I understand your Regex.
I think I'm losing my mind.
BTW, wouldn't this work just as well, but perhaps not miss things that don't use HTML?
Code: Select all
eregi("(error|warning)(.+) in (.+) on line (.+)", $page);Re: PHP Errors and Warnings list
My way is less likely to match things that aren't actual PHP errors. If it was run on this website, for example, it would match - but there are no errors here. My regexp wouldn't match. See what I mean?
Re: PHP Errors and Warnings list
I see, I was just wondering about your original post where you said.
Are you sure that the HTML produced in terms of what's bold etc. is always consistent?I'm trying to create some regexp that matches all errors, but there are a few different formats, for example:
Re: PHP Errors and Warnings list
It is for default config. Of course, this is not absolute though