News Feed
Sections




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

David Otton's Blog:
Neat PHP Tricks How To Assign References to Globals
November 10, 2008 @ 09:32:18

David Otton has a new neat PHP trick posted today - assigning references to global values.

What follows isn't so much a PHP trick as a fix for something that really should work, but doesn't. Although the manual implies that the behaviour described below is specific to Zend Engine 1, all my tests were performed against Zend Engine 2.2, PHP 5.2.5.

His example compares making a new stdClass both with and without a reference on the it and var_dumps out the result. The method with the reference fails silently, however and isn't able to correctly assign it to the global. He recommends a work-around though - setting it directly to the $GLOBALS superglobal.

0 comments voice your opinion now!
reference global superglobal trick assign object example


blog comments powered by Disqus

Similar Posts

Pádraic Brady's Blog: Complex Views with the Zend Framework - Part 2: View Helper Pattern

WeberDev.com: PHP 101 (part 11) - Sinfully Simple (SimpleXML)

Alexey Zakhlestin's Blog: Syck 0.9.2

DevShed: An Introduction to Building Proxy Classes with PHP 5

Zend Developer Zone: Decorating with External Data


Community Events

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


symfony2 introduction application framework performance laravel community voicesoftheelephpant version api series php7 interview composer library extension release opinion example podcast

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