var_dump(isset($v2)); // still set, even though passed in by reference and unset var_dump($v2); echo "---------- unsetting inside a function (static) ------------\n"; function g4() { static $count = 0; ++$count; echo "count = {$count}\n"; var_dump(isset($count)); unset($count); // unsets local "version" in current scope var_dump(isset($count)); } g4(); g4(); echo "---------- unsetting a property ------------\n"; class C { const CON1 = 123; public $prop = 10; public static $sprop = -5; } $c1 = new C(); var_dump($c1); var_dump(isset($c1->prop)); unset($c1->prop); // remove it from this instance var_dump(isset($c1->prop)); //unset(C::$sprop); // Attempt to unset static property var_dump($c1);
<?php function g4() { $arr = array(0, 1, 2, 3); $b = true; foreach ($arr as &$v) { (yield null); echo "val={$v}\n"; if ($b && $v == 1) { $b = false; array_push($arr, 4); } } } foreach (g4() as $_) { }