3v4l.org

run code in 150+ 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 $file, line $line, code $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', 'Testing if two is less than one');
Output for 5.4.8 - 5.6.28, 7.0.0 - 7.1.0
Assertion failed at file /in/tImND, line 21, code 2 < 1: Testing if two is less than one
Output for hhvm-3.10.0 - 3.12.0
Assertion failed at file /in/tImND, line 21, code 2 < 1
Output for 5.3.0 - 5.4.7
Warning: assert() expects exactly 1 parameter, 2 given in /in/tImND on line 21
Output for 4.3.0 - 5.2.17
Warning: Wrong parameter count for assert() in /in/tImND on line 21