<?php
class a{
static public $b;
static public function init(){
(self::$b)();
self::$b=function(){};
}
}
a::$b=function(){echo 'Here I do very heavy stuff, but will happen only in the first time I call init()';};
for($i=0;$i<3;$i++){
a::init();
}
Here I do very heavy stuff, but will happen only in the first time I call init()
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Here I do very heavy stuff, but will happen only in the first time I call init()
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected '(' in /in/T5J8m on line 6
Process exited with code 255.