3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 () {$fake = new Singleton(); $fake->id='hacked'; return $fake;}, $singy2, get_class($singy2)); $singy2 = $derp(); $singy2->doAction(); $singy->doAction();
Output for 5.6.28, 7.1.0
58hacked58
Output for 7.0.14
15hacked15
Output for 7.0.10
706hacked706
Output for 7.0.9
57hacked57
Output for 7.0.8
816hacked816
Output for 7.0.7
585hacked585
Output for 7.0.6
948hacked948
Output for 7.0.4 - 7.0.5
977hacked977
Output for 7.0.3
595hacked595
Output for 7.0.2
551hacked551
Output for 5.5.8, 7.0.1
1000hacked1000
Output for 7.0.0
995hacked995
Output for hhvm-3.12.0
748hacked748
Output for hhvm-3.10.0
624hacked624
Output for 5.6.25
8hacked8
Output for 5.6.24
190hacked190
Output for 5.6.23
869hacked869
Output for 5.6.22
516hacked516
Output for 5.6.21
876hacked876
Output for 5.6.20
12hacked12
Output for 5.6.19
746hacked746
Output for 5.6.18
644hacked644
Output for 5.6.17
767hacked767
Output for 5.6.16
511hacked511
Output for 5.6.15
808hacked808
Output for 5.6.14
2hacked2
Output for 5.6.13
59hacked59
Output for 5.6.12
666hacked666
Output for 5.6.11
373hacked373
Output for 5.5.11, 5.6.10
810hacked810
Output for 5.6.9
505hacked505
Output for 5.6.8
870hacked870
Output for 5.6.7
274hacked274
Output for 5.6.6
514hacked514
Output for 5.4.14, 5.6.5
886hacked886
Output for 5.6.4
626hacked626
Output for 5.6.3
967hacked967
Output for 5.6.2
535hacked535
Output for 5.6.1
186hacked186
Output for 5.6.0
498hacked498
Output for 5.5.38
653hacked653
Output for 5.5.37
16hacked16
Output for 5.5.36
610hacked610
Output for 5.5.35
134hacked134
Output for 5.5.34
871hacked871
Output for 5.5.33
355hacked355
Output for 5.5.32
543hacked543
Output for 5.5.31
693hacked693
Output for 5.5.30
426hacked426
Output for 5.4.32, 5.5.29
119hacked119
Output for 5.5.28
921hacked921
Output for 5.5.27
628hacked628
Output for 5.5.26
339hacked339
Output for 5.5.25
787hacked787
Output for 5.5.24
295hacked295
Output for 5.5.23
270hacked270
Output for 5.5.22
412hacked412
Output for 5.5.21
477hacked477
Output for 5.4.4, 5.5.20
786hacked786
Output for 5.4.22, 5.5.19
90hacked90
Output for 5.5.18
594hacked594
Output for 5.5.16
518hacked518
Output for 5.5.15
235hacked235
Output for 5.5.14
853hacked853
Output for 5.5.13
266hacked266
Output for 5.5.12
469hacked469
Output for 5.5.10
645hacked645
Output for 5.5.0, 5.5.9
766hacked766
Output for 5.5.7
903hacked903
Output for 5.5.6
685hacked685
Output for 5.5.5
361hacked361
Output for 5.5.4
764hacked764
Output for 5.5.3
922hacked922
Output for 5.5.2
913hacked913
Output for 5.5.1
958hacked958
Output for 5.4.45
173hacked173
Output for 5.4.44
679hacked679
Output for 5.4.43
114hacked114
Output for 5.4.42
897hacked897
Output for 5.4.41
907hacked907
Output for 5.4.40
650hacked650
Output for 5.4.39
425hacked425
Output for 5.4.38
896hacked896
Output for 5.4.37
422hacked422
Output for 5.4.36
962hacked962
Output for 5.4.35
488hacked488
Output for 5.4.34
708hacked708
Output for 5.4.31
347hacked347
Output for 5.4.30
158hacked158
Output for 5.4.29
683hacked683
Output for 5.4.28
714hacked714
Output for 5.4.27
950hacked950
Output for 5.4.26
647hacked647
Output for 5.4.25
720hacked720
Output for 5.4.24
744hacked744
Output for 5.4.23
300hacked300
Output for 5.4.21
389hacked389
Output for 5.4.20
658hacked658
Output for 5.4.19
252hacked252
Output for 5.4.18
951hacked951
Output for 5.4.17
298hacked298
Output for 5.4.16
246hacked246
Output for 5.4.15
193hacked193
Output for 5.4.13
515hacked515
Output for 5.4.12
84hacked84
Output for 5.4.11
60hacked60
Output for 5.4.10
216hacked216
Output for 5.4.9
846hacked846
Output for 5.4.8
579hacked579
Output for 5.4.7
448hacked448
Output for 5.4.6
85hacked85
Output for 5.4.5
272hacked272
Output for 5.4.3
556hacked556
Output for 5.4.2
22hacked22
Output for 5.4.1
341hacked341
Output for 5.4.0
569hacked569
Output for 5.3.29
911 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.28
313 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.27
243 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.26
952 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.25
549 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.24
589 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.6, 5.3.23
172 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.22
60 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.21
135 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.20
331 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.19
722 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.18
693 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.17
121 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.16
381 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.15
790 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.14
16 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.13
971 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.12
849 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.11
138 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.10
201 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.9
217 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.8
603 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.7
336 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.5
537 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.4
683 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.3
732 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.2
430 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.1
636 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.3.0
778 Fatal error: Call to undefined method Closure::bind() in /in/Suc7X on line 26
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/Suc7X 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/Suc7X 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/Suc7X on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Suc7X 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/Suc7X on line 7
Process exited with code 255.