Links to know aboutMusic The Chiara String Quartet Chiara Quartet (MySpace) Greenwood Music Camp UNL School of Music PHP PEAR Installer Manifesto phpDocumentor PEAR phar docblock PHP_Parser PHP_Parser_DocblockParser PHP_ParserGenerator PHP_LexerGenerator PEAR_PackageFileManager PHP_Archive Games_Chess Blogs Joshua Eichorn Paul M. Jones Davey Shafik Popular EntriesSetting up your own PEAR channel with Chiara_PEAR_Server - the official way
(30) Do you develop a website? It is infinitely better to synchronize live and development sites using the PEAR Installer(25) doing the PEAR thing(19) Using PEAR 1.4.0 to install PEAR packages on a remote host(19) phpDocumentor and __get/__set/__call - give us your ideas (RFC)(17) CategoriesPowered by |
Sunday, March 26. 2006subtle PHP 4 to PHP 5 difference regarding objectsRelated Links:Trackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
It is often the case that 'shady' code tends to break earlier than proper code. Treating an object as a boolean is shady at best, programming like this is asking for trouble
Next you're going to tell me that in_array works different in php4 and php5 when performed on an integer instead of an array?
I won't tell you that in_array works differently in php4 and php5, but array_merge() does work differently on NULL than it did in PHP4
Seriously, though, PHP is a loosely typed language, and as such, there are occasions where it does not work as expected. See my post on in_array(), and the unintuitive need to specify the third optional strict parameter if there is any chance that you might be comparing to a numerical string. In other words, some lazy shortcuts are built into the language intentionally. '1' == 1 and so on. !$object is a (poor) shortcut for is_object($object), and this is part of the intention of the post - to help differentiate between what is expected shortcuts (you don't have to cast string to int) and bad shortcuts (casting variables to bool to see if they are objects)
I've asked Barry to add a column with an object to his http://www.deformedweb.co.uk/php_variable_tests.php page, which is excellent to find out such differences.
|
Links in this articlePEAR Installer ManifestoCalendar
QuicksearchMy Latest ReleasesTop Exitspear.php.net (239)
www.php.net (79) pear.chiaraquartet.net (37) pecl.php.net (37) php.net (35) Blog Administration |
|||||||||||||||||||||||||||||||||||||||||||||||||