PHP Errors and Warnings list

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

PHP Errors and Warnings list

Post 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?
User avatar
akuji36
Forum Contributor
Posts: 190
Joined: Tue Oct 14, 2008 9:53 am
Location: Hartford, Connecticut

Re: PHP Errors and Warnings list

Post by akuji36 »

Something like this??

Follow this link

http://us3.php.net/manual/en/errorfunc. ... -reporting
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: PHP Errors and Warnings list

Post 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.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: PHP Errors and Warnings list

Post by JAB Creations »

User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: PHP Errors and Warnings list

Post 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 :(
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: PHP Errors and Warnings list

Post 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.
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: PHP Errors and Warnings list

Post 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)
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: PHP Errors and Warnings list

Post 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!
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: PHP Errors and Warnings list

Post 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?
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: PHP Errors and Warnings list

Post 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?
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: PHP Errors and Warnings list

Post by mikemike »

It is for default config. Of course, this is not absolute though
Post Reply