Created
May 4, 2011 08:48
-
-
Save nervetattoo/954945 to your computer and use it in GitHub Desktop.
Associativity and return by reference in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$objects = array(new stdClass, new stdClass); | |
while ($o =& next($objects) && true) | |
var_dump($o); // stdClass object | |
reset($objects); | |
while ($o = next($objects) && true) | |
var_dump($o); // true | |
// Fix | |
reset($objects); | |
while (($o = next($objects)) && true) | |
var_dump($o); // stdClass object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment