3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function test_assert($string, $arguments = array()) { // Make sure we don't pass in an empty string. assert('$string !== \'\' && (empty($arguments) || strtr($string, $arguments) !== \'\')', 'empty fail:' . $string); // Make sure we don't translate unnecessarily. assert('empty($arguments) || strtr($string, $arguments) != implode($arguments)', 'unnecesary fail: ' . $string); } test_assert('@test1', ['@test1' => 'test']); test_assert('@test2', ['@test2' => 'test']); test_assert('@test3 foo', ['@test3' => 'test3', '@test_not_used' => 'test']); test_assert('@test4 foo', ['@test4' => 'test4']); test_assert('');
based on AB2tL
Output for 7.2.0
Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/iWmnt on line 5 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/iWmnt on line 7 Warning: assert(): unnecesary fail: @test1: "empty($arguments) || strtr($string, $arguments) != implode($arguments)" failed in /in/iWmnt on line 7 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/iWmnt on line 5 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/iWmnt on line 7 Warning: assert(): unnecesary fail: @test2: "empty($arguments) || strtr($string, $arguments) != implode($arguments)" failed in /in/iWmnt on line 7 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/iWmnt on line 5 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/iWmnt on line 7 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/iWmnt on line 5 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/iWmnt on line 7 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/iWmnt on line 5 Warning: assert(): empty fail:: "$string !== '' && (empty($arguments) || strtr($string, $arguments) !== '')" failed in /in/iWmnt on line 5 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/iWmnt on line 7
Output for 5.4.8 - 7.1.10
Warning: assert(): unnecesary fail: @test1: "empty($arguments) || strtr($string, $arguments) != implode($arguments)" failed in /in/iWmnt on line 7 Warning: assert(): unnecesary fail: @test2: "empty($arguments) || strtr($string, $arguments) != implode($arguments)" failed in /in/iWmnt on line 7 Warning: assert(): empty fail:: "$string !== '' && (empty($arguments) || strtr($string, $arguments) !== '')" failed in /in/iWmnt on line 5
Output for 5.4.0 - 5.4.7
Warning: assert() expects exactly 1 parameter, 2 given in /in/iWmnt on line 5 Warning: assert() expects exactly 1 parameter, 2 given in /in/iWmnt on line 7 Warning: assert() expects exactly 1 parameter, 2 given in /in/iWmnt on line 5 Warning: assert() expects exactly 1 parameter, 2 given in /in/iWmnt on line 7 Warning: assert() expects exactly 1 parameter, 2 given in /in/iWmnt on line 5 Warning: assert() expects exactly 1 parameter, 2 given in /in/iWmnt on line 7 Warning: assert() expects exactly 1 parameter, 2 given in /in/iWmnt on line 5 Warning: assert() expects exactly 1 parameter, 2 given in /in/iWmnt on line 7 Warning: assert() expects exactly 1 parameter, 2 given in /in/iWmnt on line 5 Warning: assert() expects exactly 1 parameter, 2 given in /in/iWmnt on line 7
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/iWmnt on line 10
Process exited with code 255.