3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function test1($unset = false) { static $bar = 1; $bar++; echo $bar; unset($bar); echo $bar; $bar = "|"; echo $bar; // this initialization value is hoisted to the top of the function! static $bar = 5; $bar++; echo $bar; echo " "; } test1(); test1(); test1(); test1();
Output for 5.0.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
6 Notice: Undefined variable: bar in /in/hqXho on line 11 |7 8 Notice: Undefined variable: bar in /in/hqXho on line 11 |9 10 Notice: Undefined variable: bar in /in/hqXho on line 11 |11 12 Notice: Undefined variable: bar in /in/hqXho on line 11 |13
Output for 4.3.0 - 5.0.3
6 Notice: Undefined variable: bar in /in/hqXho on line 11 |7 8 Notice: Undefined variable: bar in /in/hqXho on line 11 |9 10 Notice: Undefined variable: bar in /in/hqXho on line 11 |11 12 Notice: Undefined variable: bar in /in/hqXho on line 11 |13