3v4l.org

run code in 300+ PHP versions simultaneously
<?php $possible0 = explode(',', 'hello, world', -100); $possible1 = explode(',', 'hello, world', -1); $possible2 = explode(',', 'hello, world', 0); $possible3 = explode(',', 'hello, world', 1); $possible4 = explode(',', 'hello, world', 2); $possible5 = explode(',', 'hello, world', 3); $possible6 = explode(',', 'hello, world', 4); try { $impossible1 = explode('', '', -1); } catch (Throwable $impossible1) {} $traced = [$possible0, $possible1, $possible2, $possible3, $possible4, $possible5, $possible6, $impossible1]; /** @psalm-trace $traced */ var_dump($traced); return $traced;
Output for 8.4.1
array(8) { [0]=> array(0) { } [1]=> array(1) { [0]=> string(5) "hello" } [2]=> array(1) { [0]=> string(12) "hello, world" } [3]=> array(1) { [0]=> string(12) "hello, world" } [4]=> array(2) { [0]=> string(5) "hello" [1]=> string(6) " world" } [5]=> array(2) { [0]=> string(5) "hello" [1]=> string(6) " world" } [6]=> array(2) { [0]=> string(5) "hello" [1]=> string(6) " world" } [7]=> object(ValueError)#1 (7) { ["message":protected]=> string(53) "explode(): Argument #1 ($separator) must not be empty" ["string":"Error":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/0NKlW" ["line":protected]=> int(11) ["trace":"Error":private]=> array(1) { [0]=> array(4) { ["file"]=> string(9) "/in/0NKlW" ["line"]=> int(11) ["function"]=> string(7) "explode" ["args"]=> array(3) { [0]=> string(0) "" [1]=> string(0) "" [2]=> int(-1) } } } ["previous":"Error":private]=> NULL } }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14
array(8) { [0]=> array(0) { } [1]=> array(1) { [0]=> string(5) "hello" } [2]=> array(1) { [0]=> string(12) "hello, world" } [3]=> array(1) { [0]=> string(12) "hello, world" } [4]=> array(2) { [0]=> string(5) "hello" [1]=> string(6) " world" } [5]=> array(2) { [0]=> string(5) "hello" [1]=> string(6) " world" } [6]=> array(2) { [0]=> string(5) "hello" [1]=> string(6) " world" } [7]=> object(ValueError)#1 (7) { ["message":protected]=> string(51) "explode(): Argument #1 ($separator) cannot be empty" ["string":"Error":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/0NKlW" ["line":protected]=> int(11) ["trace":"Error":private]=> array(1) { [0]=> array(4) { ["file"]=> string(9) "/in/0NKlW" ["line"]=> int(11) ["function"]=> string(7) "explode" ["args"]=> array(3) { [0]=> string(0) "" [1]=> string(0) "" [2]=> int(-1) } } } ["previous":"Error":private]=> NULL } }
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 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
Warning: explode(): Empty delimiter in /in/0NKlW on line 11 array(8) { [0]=> array(0) { } [1]=> array(1) { [0]=> string(5) "hello" } [2]=> array(1) { [0]=> string(12) "hello, world" } [3]=> array(1) { [0]=> string(12) "hello, world" } [4]=> array(2) { [0]=> string(5) "hello" [1]=> string(6) " world" } [5]=> array(2) { [0]=> string(5) "hello" [1]=> string(6) " world" } [6]=> array(2) { [0]=> string(5) "hello" [1]=> string(6) " world" } [7]=> bool(false) }
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/0NKlW on line 14
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/0NKlW on line 14
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/0NKlW on line 10
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 '{' in /in/0NKlW on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/0NKlW on line 10
Process exited with code 255.

preferences:
93.26 ms | 417 KiB | 5 Q