3v4l.org

run code in 300+ PHP versions simultaneously
<?php function shenanigans(string &$foo) { return function () use (&$foo) { $foo = 'But this action at a distance is annoying.'; }; $foo = "I can expect it is changed inside function"; } $somestring = "original value"; $fn = shenanigans($somestring); var_dump($somestring); // many lines of code here // many lines of code here // many lines of code here $fn(); var_dump($somestring);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
191.69 ms | 1733 KiB | 12 Q