3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function test1($unset = false) { static $bar = 1; $bar++; echo $bar; unset($bar); $bar = "|"; echo $bar; // this initialization value is hoisted to the top of the function! static $bar = 5; $bar++; echo $bar; echo " "; static $bar = 77; } test1(); var_dump($bar); test1(); test1(); test1();
Output for 5.0.4 - 7.1.0
78|79 Notice: Undefined variable: bar in /in/41CGK on line 25 NULL 80|81 82|83 84|85
Output for 4.3.0 - 5.0.3
78|79 Notice: Undefined variable: bar in /in/41CGK on line 25 NULL 80|81 82|83 84|85