3v4l.org

run code in 300+ PHP versions simultaneously
<?php class LazyValue { public function __construct( private Closure $lazy, ){} public function getValue() { static $value = ($this->lazy)(); return $value; } } $t1 = new LazyValue(function () { echo "slow\n"; return "42\n"; }); echo $t1->getValue(); echo $t1->getValue(); echo $t1->getValue();

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
156.67 ms | 1598 KiB | 10 Q