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

Johannes Schluter's Blog:
References and foreach
August 20, 2010 @ 12:44:35

To reinforce a point he's made before (references in PHP are bad) Johannes Schluter has posted an example to his blog of a specific instance that causes an (expected) issue with references and foreach loops.

Now there is one use case which leads to an, at first, unexpected behavior which I didn't see as a real live issue when I stumbled over it at first, but then there were a few bug reports about it and recently a friend asked me about it ... so here it goes.

He show a code snippet of looping over an array with two foreaches and a print_r that shows the bug - the array changed from the original for no clearly apparent reason. To understand why this happens, he goes into detail on how variables are handled - complete with graphs.

1 comment voice your opinion now!
references foreach array bug handling variable


blog comments powered by Disqus

Similar Posts

AskAboutPHP.com: Codeigniter: Mixing segment-based URL with querystrings

phpRiot.com: Using the PHP 5 Iterator interface with Smarty

Zend Developer Zone: Announcing the December 2010 Zend Framework Bug-Hunt

PHPClasses.org: Lately in PHP Podcast Episode 21 - Is PHP Source Quality Really Good?

Matthew Turland's Blog: Interesting Bug in the HTTP Streams Wrapper


Community Events











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


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

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