Skip to content

Instantly share code, notes, and snippets.

@asm89
Created January 18, 2014 13:27
Show Gist options
  • Save asm89/8490526 to your computer and use it in GitHub Desktop.
Save asm89/8490526 to your computer and use it in GitHub Desktop.
<?php
$xs = array(42);
foreach ($xs as $x) {}
var_dump(current($xs));
$ys = array(42);
foreach ($ys as &$y) {}
var_dump(current($ys));
$it = new ArrayIterator([42]);
foreach($it as $i){}
var_dump($it->current());
$it2 = (new ArrayObject([42]))->getIterator();
foreach($it2 as $i){}
var_dump($it2->current());
@asm89
Copy link
Author

asm89 commented Jan 18, 2014

~ $ hhvm /tmp/d.php 
int(42)
bool(false)
bool(false)
bool(false)
~ $ php /tmp/d.php 
bool(false)
bool(false)
NULL
NULL
~ $ hhvm --version
HipHop VM v2.4.0-dev (rel)
Compiler: heads/datetime-0-g2af4254e176781070ffea624f2c4f5fb1e458f15
Repo schema: c0810d54facf76dace1ea4a9f11fa64bcdaa0e61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment