News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Ben Ramsey's Blog:
Undefined Constant Is a String?
December 21, 2006 @ 07:34:00

Constants can be handy when used correctly. Unfortunately, there's some small issues you might want to watch out for. Ben Ramsey discovered one while working with another's code - an undefined constant acting like a string.

From the I-noticed-this-one-day-while-looking-at-a-co-worker's-code department comes a tale about the use of undefined constants in PHP'"and relying on this twisted "feature" to make an application function properly.

He relays a little story about the errant code and noticed the constant that wasn't defined and how PHP was treating it like a string. After searching the manual, though, he finds a reference related to the situation showing that it will only throw an E_NOTICE when this happens.

Ben's suggestion is for a bit more than that - at the very least an E_WARNING. Having it down at E_NOTICE won't be seen by most with the default php.ini, and he gives an example as to why it's a bad thing (passing this string/constant into a function and how it handles it).

0 comments voice your opinion now!
undefined constant string value enotice ewarning phpiin undefined constant string value enotice ewarning phpiin


Wez Furlong's Blog:
Undefined Behaviour
April 29, 2006 @ 07:59:43

Spurred on by some comments made in a thread on the php internals mailing list, Wez Furlong has posted this new item on his blog to help clear up some of the confusion around some "undefined behaviour" in the PDO libraries.

In this thread on the php internals list, Kevin is asking why the handling of whitespace in certain PDO DSNs is inconsistent. I go on to point out that the manual doesn't say anything about whitespace in DSNs, and that all the documented examples have no whitespace around the DSN parameters.

This is an example of undefined behaviour. The PHP manual doesn't define what happens when you put whitespace in there. That doesn't tell you anything at all about whether you should or should not do that. It might work now, and it might work next week. In 6 months time, when you application is widely deployed and someone changes an apparently unrelated part of their system, it might NOT work and might result in someone getting paged at 3am trying to figure out what the mysterious problem is.

Wez goes on to mention that there are some issues with this in the Solaris manual pages as well, as based on others running into this same sort of problem. The realy key here, though, is how the documenttion is defined. Developers, in his opinion, show always treat situations that aren't expressly defined by the manual as a "situation is undefined" rather than making their own expectations.

0 comments voice your opinion now!
undefined behaviour pdo library documentation solaris undefined behaviour pdo library documentation solaris


3greeneggs.com:
What do those PHP errors really mean, anyway?
February 03, 2006 @ 06:52:16

In this blog post today, ephemera looks at a few of the common PHP errors those new to the language might encounter and an inerpretation of each.

I'd like to dispell the myth that errors are a bad thing. Errors are not a bad thing. Errors are a good thing! They tell you exactly what to fix, and exactly where to fix it. The only mystery is in actually interpretting the language of the error, which is another skill that beginning coders have yet to master. What does the PHP interpreter really mean when it says "unexpected T_VARIABLE"? What's a T_VARIABLE, anyway?

This document is the first in a series that will attempt to help you decode error messages. This version is aimed at very new programmers, working in PHP.

The remainder of the post looks at four of the common errors that might pop up - "unexpected T_VARIABLE", "Maximum execution time exceeded", "Undefined index", and "Syntax error". Under each, she talks about what they mean and how to catch what they're referring to. There's also an example for each to show what the error-causing code might look like.

0 comments voice your opinion now!
errors meaning t_variable max time undefined index syntax errors meaning t_variable max time undefined index syntax


Nexen.net:
Error Messages in PHP (a Search)
December 29, 2005 @ 07:04:09

PHP can throw out some pretty cryptic error messages sometimes, and those new to the langauge might have a difficult time understanding what they relate to. Well, Nexen.net has created a guide to the errors to help you make your way through them (as mentioned in this post).

The errors that PHP throws can sometimes be confusing and mysterious. It outputs them in an effort to make debugging your scripts easier so you can go and correct the error. To help with deciphering them, we have created a guide by looking at the source code for PHP versions: 4.0.0, 4.0.6, 4.1.2, 4.2.3, 4.3.6 and 5.0.0RC2. versions 4.3.6 and 5.0.0RC2.

On the tool they've created, all you need to do is enter in the error code number that the script spits back and it will show you the relevant information. It also has a listing of some of the samples below it to help you narrow it down quickly if you already know what you're looking for.

The site and the tool are all in French.

2 comments voice your opinion now!
search error messages undefined index parse search error messages undefined index parse



Community Events





Don't see your event here?
Let us know!


configure list install application api threedevsandamaybe symfony code language podcast laravel bugfix release wordpress library introduction community developer series interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework