News Feed
Sections




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

Ibuildings Blog:
Accessing object properties by reference
May 05, 2008 @ 14:38:49

On the Ibuildings blog today, Harrie Verveer has posted about an interesting quirk he found when working with objects and references:

PHP is a loosely typed language. Most of the time this is very useful because you as a programmer don't have to worry about typecasting: it's done for you. However, on some occasions this can cause some unexpected trouble. [...] In this blog I want to point out what can happen if you try to access object properties by reference when the object is not initialized.

His example shows the problem when it tries to grab a value from an array in a non-existent object by reference. It results in a dyanamically created object (of that type) with an empty array inside of it. It only works when you grab it by reference, but he shares a tip or two about how you can prevent hard to track down issues like this.

0 comments voice your opinion now!
property object reference find difficult issue


blog comments powered by Disqus

Similar Posts

php|architect: 7 Promotions for 7 Days - January 5th - Any PDF Issue for $0.99 USD

Stefan Mischook's Blog: A Question about object properties in PHP Classes

Byster.net: PHP5 Benchmarks

Stefan Mischook's Blog: Why learn OOP in PHP - another take

Giorgio Sironi's Blog: Lazy loading of objects from database


Community Events





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


bugfix code symfony api voicesoftheelephpant interview zendserver laravel deployment podcast threedevsandamaybe introduction conference series tips release language community framework list

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