Page 1 of 1
PHP Errors and Warnings list
Posted: Fri Jun 12, 2009 11:26 am
by mikemike
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?
Re: PHP Errors and Warnings list
Posted: Fri Jun 12, 2009 1:19 pm
by akuji36
Re: PHP Errors and Warnings list
Posted: Fri Jun 12, 2009 2:04 pm
by mikemike
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:
Code: Select all
"(error</b>:)(.+) in <b>(.+)</b> on line <b>(.+)</b>"
at the moment, but that doesn't match everything, only syntax errors and the like.
Re: PHP Errors and Warnings list
Posted: Fri Jun 12, 2009 9:34 pm
by JAB Creations
Re: PHP Errors and Warnings list
Posted: Fri Jun 12, 2009 10:54 pm
by mikemike
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
Posted: Fri Jun 12, 2009 11:42 pm
by omniuni
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.
Re: PHP Errors and Warnings list
Posted: Sat Jun 13, 2009 7:08 am
by mikemike
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
Posted: Sun Jun 14, 2009 5:03 pm
by omniuni
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?
Code: Select all
eregi("(error|warning)(.+) in (.+) on line (.+)", $page);
Edit: Cool! That's how you make it do PHP syntax highlighting!
Re: PHP Errors and Warnings list
Posted: Sun Jun 14, 2009 5:07 pm
by mikemike
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
Posted: Sun Jun 14, 2009 7:47 pm
by omniuni
I see, I was just wondering about your original post where you said.
I'm trying to create some regexp that matches all errors, but there are a few different formats, for example:
Are you sure that the HTML produced in terms of what's bold etc. is always consistent?
Re: PHP Errors and Warnings list
Posted: Tue Jul 21, 2009 5:38 pm
by mikemike
It is for default config. Of course, this is not absolute though