3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hooks = ['before' => [], 'after' => []]; function echoSomething($something) { global $hooks; array_walk($hooks['before'], function($function)use($something) { call_user_func($function, $something); }); echo $something; array_walk($hooks['after'], function($function)use($something) { call_user_func($function, $something); }); } echoSomething('Hello, world'); echo PHP_EOL, '//-------------------------', PHP_EOL; $hooks['before'][] = function() { echo '<b>'; }; $hooks['after'][] = function() { echo '</b>'; }; echoSomething('Hello, world'); echo PHP_EOL, '//-------------------------', PHP_EOL;

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
171.2 ms | 2847 KiB | 11 Q