News Feed
Jobs Feed
Sections




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

Greg Beaver's Blog:
subtle PHP 4 to PHP 5 difference regarding objects
March 27, 2006 @ 07:05:53

PHP has a lot going on "under the hood" for each request that's made, so its no wonder that issues with PHP5 code might see some problems when shifted down to PHP4. Greg Beaver caught something in the PEAR installer centered around objects.

Recently, some code in the PEAR installer was discovered to be invalid in PHP 4. After a bit of investigation, I realized that the significant difference in the way objects are represented internally in PHP 5 was the culprit.

In PHP 5, this displays as bool(true), but in PHP 4, it displays bool(false). The reason is that in PHP 4, objects are simply glorified associative arrays, and so PHP treats the above [example] code exactly the same.

He strongly suggests that, to help with this issue, you always check to ensure (with is_object) that what you're passing is a true object.

He's made an update to the post since it was originally released, mentioning how some classes will also define their own cast handlers.

0 comments voice your opinion now!
objects php4 php5 difference internal cast handler objects php4 php5 difference internal cast handler


blog comments powered by Disqus

Similar Posts

DevShed: Using Unbuffered Queries and More with SQLite with PHP 5

Insane Security Blog: PHP 5.2+ Data Filtering Extension = BAD?

Gennady Feldman's Blog: Migration to PHP5 links and articles

Andi Gutmans' Blog: PHP 5 Adoption has Tipped!

Lukas Smith's Blog: Who is using namespaces in PHP already?


Community Events











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


hhvm security code overview podcast unittest symfony2 install release component application language composer opinion framework threedevsandamaybe hack facebook package introduction

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