3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function a () { static $ax = 0; function b() { static $bx = 0; echo "I am ".__FUNCTION__.". I have been called ".$bx++." times\n"; } echo "I am ".__FUNCTION__.". I have been called ".$ax++." times\n"; } echo function_exists("b") ? "b is defined\n" : "b is not defined\n"; a(); echo function_exists("b") ? "b is defined\n" : "b is not defined\n"; b(); a(); echo function_exists("b") ? "b is defined\n" : "b is not defined\n";
based on oODqT
Output for 4.3.2 - 7.1.0
b is not defined I am a. I have been called 0 times b is defined I am b. I have been called 0 times Fatal error: Cannot redeclare b() (previously declared in /in/eoioA:6) in /in/eoioA on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
b is not defined I am a. I have been called 0 times b is defined I am b. I have been called 0 times Fatal error: Cannot redeclare b() (previously declared in /in/eoioA:6) in /in/eoioA on line 5