3v4l.org

run code in 300+ PHP versions simultaneously
<?php class bla { private $name; function __construct() { $this->name = 'I am this'; echo "We are in\n"; } function dontTouchThis() { return 'not this'; } function touchThis() { return $this->name; } } $lazyBla = (new \ReflectionClass('bla'))->newLazyProxy(function () { return new bla(); }); $whatsThat = $lazyBla->dontTouchThis(); echo $whatsThat . "\n\n"; $whatsThis = $lazyBla->touchThis(); echo $whatsThis . "\n\n"; $bla = new bla;
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.4.5 - 8.4.14
not this We are in I am this We are in
Output for 8.2.28 - 8.2.29, 8.3.5 - 8.3.27
Fatal error: Uncaught Error: Call to undefined method ReflectionClass::newLazyProxy() in /in/OERUAl:22 Stack trace: #0 {main} thrown in /in/OERUAl on line 22
Process exited with code 255.

preferences:
74.39 ms | 409 KiB | 5 Q