3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ""; function foo() { return "bar"; } $eval = '$a = ' .foo() . ';'; var_dump($eval); eval($eval); echo $a;
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
string(9) "$a = bar;" Fatal error: Uncaught Error: Undefined constant "bar" in /in/ISKsV(12) : eval()'d code:1 Stack trace: #0 /in/ISKsV(12): eval() #1 {main} thrown in /in/ISKsV(12) : eval()'d code on line 1
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
string(9) "$a = bar;" Warning: Use of undefined constant bar - assumed 'bar' (this will throw an Error in a future version of PHP) in /in/ISKsV(12) : eval()'d code on line 1 bar
Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
string(9) "$a = bar;" Notice: Use of undefined constant bar - assumed 'bar' in /in/ISKsV(12) : eval()'d code on line 1 bar

preferences:
189.74 ms | 402 KiB | 215 Q