News Feed
Jobs Feed
Sections




News Archive
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

Nefarious Designs: Object-Oriented PHP Part 4: PHP5's Improved Features

CatsWhoCode.com: 15 PHP regular expressions for web developers

Wojciech Sznapka's Blog: Loosening dependencies with closures in PHP

KillerPHP.com: The Zend Framework: Writing Object-Oriented PHP with Ease

Hasin Hayder's Blog: Getting started with orchid framework


Community Events









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


functional conference object testing example podcast interview api framework opinion composer language introduction community development code phpunit event release zendframework2

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