3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Active assert and make it quiet assert_options(ASSERT_ACTIVE, 1); assert_options(ASSERT_WARNING, 0); assert_options(ASSERT_QUIET_EVAL, 1); // Create a handler function function my_assert_handler($file, $line, $code, $desc = null) { echo "Assertion failed at $file:$line: $code"; if ($desc) { echo ": $desc"; } echo "\n"; } // Set up the callback assert_options(ASSERT_CALLBACK, 'my_assert_handler'); // Make an assertion that should fail assert('2 < 1'); assert('2 < 1', 'Two is less than one');
Output for 7.2.0
Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/B10A2 on line 21 Assertion failed at /in/B10A2:21: 2 < 1 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/B10A2 on line 22 Assertion failed at /in/B10A2:22: 2 < 1: Two is less than one
Output for 5.4.8 - 7.1.10
Assertion failed at /in/B10A2:21: 2 < 1 Assertion failed at /in/B10A2:22: 2 < 1: Two is less than one
Output for 5.3.0 - 5.4.7
Assertion failed at /in/B10A2:21: 2 < 1 Warning: assert() expects exactly 1 parameter, 2 given in /in/B10A2 on line 22
Output for 4.3.0 - 5.2.17
Assertion failed at /in/B10A2:21: 2 < 1 Warning: Wrong parameter count for assert() in /in/B10A2 on line 22