3v4l.org

run code in 300+ PHP versions simultaneously
<?php function f(){} f(print "Jack\n"); $a=null; f(print ++$a . "\n"); print strlen(4) . "\n"; class C { function C(){} } new C(print ++$a); $a = 10; echo "\nCount: ",count($a),"\n"; $n=NULL; $nn = $n; --$nn; $n++; var_dump($nn,$n); $s = "mehea"; $s++; var_dump($s); $s--; var_dump($s); class A { } class B extends A { public function __construct() { // make sure parent constructor gets called if someone adds one parent::__construct(); } } new B();
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Jack 1 1 2 Count: Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given in /in/bTsZK:13 Stack trace: #0 {main} thrown in /in/bTsZK on line 13
Process exited with code 255.
Output for 8.0.0 - 8.0.9
Jack 1 1 2 Count: Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, int given in /in/bTsZK:13 Stack trace: #0 {main} thrown in /in/bTsZK on line 13
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; C has a deprecated constructor in /in/bTsZK on line 8 Jack 1 1 2 Count: Warning: count(): Parameter must be an array or an object that implements Countable in /in/bTsZK on line 13 1 NULL int(1) string(5) "meheb" string(5) "meheb" Fatal error: Uncaught Error: Cannot call constructor in /in/bTsZK:31 Stack trace: #0 /in/bTsZK(35): B->__construct() #1 {main} thrown in /in/bTsZK on line 31
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Jack 1 1 2 Count: Warning: count(): Parameter must be an array or an object that implements Countable in /in/bTsZK on line 13 1 NULL int(1) string(5) "meheb" string(5) "meheb" Fatal error: Uncaught Error: Cannot call constructor in /in/bTsZK:31 Stack trace: #0 /in/bTsZK(35): B->__construct() #1 {main} thrown in /in/bTsZK on line 31
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; C has a deprecated constructor in /in/bTsZK on line 8 Jack 1 1 2 Count: 1 NULL int(1) string(5) "meheb" string(5) "meheb" Fatal error: Uncaught Error: Cannot call constructor in /in/bTsZK:31 Stack trace: #0 /in/bTsZK(35): B->__construct() #1 {main} thrown in /in/bTsZK on line 31
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
Jack 1 1 2 Count: 1 NULL int(1) string(5) "meheb" string(5) "meheb" Fatal error: Cannot call constructor in /in/bTsZK on line 31
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
Jack 1 1 2 Count: 1 NULL int(1) string(5) "meheb" string(5) "meheb" Fatal error: Can not call constructor in /in/bTsZK on line 31
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/bTsZK on line 29
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/bTsZK on line 29
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/bTsZK on line 29
Process exited with code 255.

preferences:
314.86 ms | 401 KiB | 459 Q