3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$in2 = Closure::bind(function () {$this->ruler = 'jesus';}, $inst, get_class($inst)); class Singleton { protected static $instance; // object instance private function __construct(){ /* ... @return Singleton */ } // Защищаем от создания через new Singleton private function __clone() { /* ... @return Singleton */ } // Защищаем от создания через клонирование private function __wakeup() { /* ... @return Singleton */ } // Защищаем от создания через unserialize public static function getInstance() { // Возвращает единственный экземпляр класса. @return Singleton if ( !isset(self::$instance) ) { $class = __CLASS__; self::$instance = new $class(); self::$instance->id = mt_rand(1,1000); } return self::$instance; } public function doAction() { echo $this->id; } } $singy = Singleton::getInstance(); $singy->doAction(); $singy2 = Singleton::getInstance(); $derp = Closure::bind(function () {$this->id = 'HACKED';}, $singy2, get_class($singy2)); $derp(); $singy2->doAction(); $singy->doAction();
Output for 7.3.1
416HACKEDHACKED
Output for 7.3.0
402HACKEDHACKED
Output for 7.2.13
42HACKEDHACKED
Output for 7.2.12
68HACKEDHACKED
Output for 7.2.11
91HACKEDHACKED
Output for 7.2.10
873HACKEDHACKED
Output for 7.2.9
245HACKEDHACKED
Output for 7.2.8
972HACKEDHACKED
Output for 7.2.7
859HACKEDHACKED
Output for 7.2.6
764HACKEDHACKED
Output for 7.2.5
969HACKEDHACKED
Output for 5.4.44, 7.2.4
530HACKEDHACKED
Output for 7.2.3
436HACKEDHACKED
Output for 7.2.2
657HACKEDHACKED
Output for 7.2.1
102HACKEDHACKED
Output for 7.2.0
459HACKEDHACKED
Output for 7.1.25
882HACKEDHACKED
Output for 7.1.7
693HACKEDHACKED
Output for 7.1.6
351HACKEDHACKED
Output for 7.1.5
33HACKEDHACKED
Output for 7.1.0
556HACKEDHACKED
Output for 7.0.20
901HACKEDHACKED
Output for 7.0.14
127HACKEDHACKED
Output for 7.0.12
557HACKEDHACKED
Output for 7.0.6
62HACKEDHACKED
Output for 7.0.5
814HACKEDHACKED
Output for 7.0.4
756HACKEDHACKED
Output for 7.0.3
263HACKEDHACKED
Output for 5.4.18, 7.0.2
851HACKEDHACKED
Output for 7.0.1
118HACKEDHACKED
Output for 7.0.0
964HACKEDHACKED
Output for 5.6.28
676HACKEDHACKED
Output for 5.6.21
825HACKEDHACKED
Output for 5.6.20
110HACKEDHACKED
Output for 5.6.19
875HACKEDHACKED
Output for 5.6.18
836HACKEDHACKED
Output for 5.6.17
743HACKEDHACKED
Output for 5.6.16
354HACKEDHACKED
Output for 5.6.15
236HACKEDHACKED
Output for 5.6.14
421HACKEDHACKED
Output for 5.6.13
462HACKEDHACKED
Output for 5.6.12
902HACKEDHACKED
Output for 5.6.11
114HACKEDHACKED
Output for 5.6.10
903HACKEDHACKED
Output for 5.6.9
724HACKEDHACKED
Output for 5.6.8
923HACKEDHACKED
Output for 5.4.25, 5.6.7
148HACKEDHACKED
Output for 5.6.6
348HACKEDHACKED
Output for 5.6.5
674HACKEDHACKED
Output for 5.6.4
81HACKEDHACKED
Output for 5.6.3
135HACKEDHACKED
Output for 5.6.2
82HACKEDHACKED
Output for 5.6.1
699HACKEDHACKED
Output for 5.6.0
257HACKEDHACKED
Output for 5.5.35
515HACKEDHACKED
Output for 5.5.34
219HACKEDHACKED
Output for 5.5.33
126HACKEDHACKED
Output for 5.5.32
808HACKEDHACKED
Output for 5.5.31
239HACKEDHACKED
Output for 5.5.30
338HACKEDHACKED
Output for 5.5.29
534HACKEDHACKED
Output for 5.5.28
10HACKEDHACKED
Output for 5.5.27
883HACKEDHACKED
Output for 5.5.26
369HACKEDHACKED
Output for 5.5.25
454HACKEDHACKED
Output for 5.5.24
533HACKEDHACKED
Output for 5.5.23
810HACKEDHACKED
Output for 5.5.22
499HACKEDHACKED
Output for 5.5.21
163HACKEDHACKED
Output for 5.5.20
847HACKEDHACKED
Output for 5.5.19
145HACKEDHACKED
Output for 5.5.18
931HACKEDHACKED
Output for 5.5.16
422HACKEDHACKED
Output for 5.5.15
372HACKEDHACKED
Output for 5.5.14
614HACKEDHACKED
Output for 5.5.13
384HACKEDHACKED
Output for 5.5.12
96HACKEDHACKED
Output for 5.5.11
143HACKEDHACKED
Output for 5.5.10
552HACKEDHACKED
Output for 5.5.9
638HACKEDHACKED
Output for 5.5.8
13HACKEDHACKED
Output for 5.5.7
893HACKEDHACKED
Output for 5.5.6
952HACKEDHACKED
Output for 5.5.5
878HACKEDHACKED
Output for 5.5.4
671HACKEDHACKED
Output for 5.5.3
773HACKEDHACKED
Output for 5.5.2
302HACKEDHACKED
Output for 5.5.1
858HACKEDHACKED
Output for 5.5.0
311HACKEDHACKED
Output for 5.4.45
940HACKEDHACKED
Output for 5.4.43
84HACKEDHACKED
Output for 5.4.42
375HACKEDHACKED
Output for 5.4.27, 5.4.41
513HACKEDHACKED
Output for 5.4.40
298HACKEDHACKED
Output for 5.4.39
475HACKEDHACKED
Output for 5.4.38
276HACKEDHACKED
Output for 5.4.37
949HACKEDHACKED
Output for 5.4.36
518HACKEDHACKED
Output for 5.4.35
846HACKEDHACKED
Output for 5.4.34
620HACKEDHACKED
Output for 5.4.32
183HACKEDHACKED
Output for 5.4.31
8HACKEDHACKED
Output for 5.4.30
233HACKEDHACKED
Output for 5.4.29
282HACKEDHACKED
Output for 5.4.28
730HACKEDHACKED
Output for 5.4.26
105HACKEDHACKED
Output for 5.4.16, 5.4.24
456HACKEDHACKED
Output for 5.4.23
173HACKEDHACKED
Output for 5.4.22
358HACKEDHACKED
Output for 5.4.21
797HACKEDHACKED
Output for 5.4.20
926HACKEDHACKED
Output for 5.4.19
669HACKEDHACKED
Output for 5.4.17
548HACKEDHACKED
Output for 5.4.15
862HACKEDHACKED
Output for 5.4.14
28HACKEDHACKED
Output for 5.4.13
855HACKEDHACKED
Output for 5.4.12
981HACKEDHACKED
Output for 5.4.11
544HACKEDHACKED
Output for 5.4.10
826HACKEDHACKED
Output for 5.4.9
637HACKEDHACKED
Output for 5.4.8
134HACKEDHACKED
Output for 5.4.7
950HACKEDHACKED
Output for 5.4.6
644HACKEDHACKED
Output for 5.4.5
133HACKEDHACKED
Output for 5.4.4
344HACKEDHACKED
Output for 5.4.3
928HACKEDHACKED
Output for 5.4.2
728HACKEDHACKED
Output for 5.4.1
254HACKEDHACKED
Output for 5.4.0
958HACKEDHACKED
Output for 5.3.29
897 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.28
883 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.27
476 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.26
28 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.25
375 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.24
404 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.23
330 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.22
422 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.21
112 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.20
18 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.19
768 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.18
963 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.17
484 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.16
39 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.15
792 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.14
923 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.13
44 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.12
203 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.11
677 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.10
943 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.9
464 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.8
26 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.7
870 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.6
521 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.5
742 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.4
435 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.3
763 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.2
733 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.1
341 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.3.0
545 Fatal error: Call to undefined method Closure::bind() in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/cvTpA on line 26
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/cvTpA on line 26
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/cvTpA on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/cvTpA on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/cvTpA on line 7
Process exited with code 255.

preferences:
161.17 ms | 401 KiB | 222 Q