3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SingletonTest { protected static $_instance; private function __construct(){} private function __clone(){} public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; } } class PrivacyViolator { private $_caller; function __construct() { $this->_caller = function ($method, $args) { return call_user_func_array([$this, $method], $args); }; } function callPrivateMethod($object, $method, $args) { $this->_caller->bindTo($object, $object); return $this->_caller($method, $args); } } $myObject = SingletonTest::getInstance(); $privacyViolator = new PrivacyViolator(); $newObject = $privacyViolator->callPrivateMethod($myObject, '__construct', []);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined method PrivacyViolator::_caller() in /in/S5j87:36 Stack trace: #0 /in/S5j87(42): PrivacyViolator->callPrivateMethod(Object(SingletonTest), '__construct', Array) #1 {main} thrown in /in/S5j87 on line 36
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
51.61 ms | 401 KiB | 8 Q