3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Singleton { private static $instance; private function __construct() {} private function __clone() {} private function __wakeup() {} public static function getInstance() { if (empty(self::$instance)) self::$instance = new self(); return self::$instance; } } $Object1 = Singleton::getInstance(); // ------------------------------------------------------- class PrivacyViolator { private $_caller; function __construct() { $this->_caller = function ($method, $args) { return call_user_func_array([$this, $method], $args); }; } function callPrivateMethod($object, $method, $args) { return $this->_caller->bindTo($object, $object)->__invoke($method, $args); } } $privacyViolator = new PrivacyViolator(); $c = $privacyViolator->callPrivateMethod($Object1, '__construct', []); echo $Object1 == $c ? '+' : '-'; echo $Object1 === $c ? '+' : '-';
based on ffI8A
Output for 5.4.2 - 7.2.0
--
Output for 5.3.17 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/ss2mX on line 29
Process exited with code 255.