3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); // print() ignores strict_types... print(1 + 2) * 3; // outputs "9"; the parentheses cause 1+2 to be evaluated first, then 3*3 // the print statement sees the whole expression as one argument // As for the type mismatch? the strict_types ? ignored.. echo "\n"; if ( print("hello") && false ) { print "WTF: inside if"; } else { print "OK: inside else"; } echo "\n"; if ( 1 && false ) { print "WTF: inside if"; } else { print "OK: inside else"; } echo "\n"; print "hello " && print "world"; // outputs "world1"; ... WTF? echo "\n"; ob_start(); print "hello " && print "world"; $str = ob_get_clean(); assert(str_contains($str, 'hello'));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
9 WTF: inside if OK: inside else world1 Fatal error: Uncaught AssertionError: assert(str_contains($str, 'hello')) in /in/1YXYk:36 Stack trace: #0 /in/1YXYk(36): assert(false, 'assert(str_cont...') #1 {main} thrown in /in/1YXYk on line 36
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
9 WTF: inside if OK: inside else world1 Fatal error: Uncaught Error: Call to undefined function str_contains() in /in/1YXYk:36 Stack trace: #0 {main} thrown in /in/1YXYk on line 36
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Warning: Unsupported declare 'strict_types' in /in/1YXYk on line 2 9 WTF: inside if OK: inside else world1 Fatal error: Call to undefined function str_contains() in /in/1YXYk on line 36
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
9 WTF: inside if OK: inside else world1 Fatal error: Call to undefined function str_contains() in /in/1YXYk on line 36
Process exited with code 255.
Output for 4.4.5 - 4.4.9
9 WTF: inside if OK: inside else world1 Fatal error: Call to undefined function: str_contains() in /in/1YXYk on line 36
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
9 WTF: inside if OK: inside else world1 Fatal error: Call to undefined function: str_contains() in /in/1YXYk on line 36
Process exited with code 255.
Output for 4.3.0 - 4.3.1
9 WTF: inside if OK: inside else world1 Fatal error: Call to undefined function: str_contains() in /in/1YXYk on line 36

preferences:
65.62 ms | 412 KiB | 5 Q