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 () {return new Singleton();}, $singy2, get_class($singy2)); $singy2 = $derp(); $singy2->doAction(); $singy->doAction();
Output for 7.1.0
68 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 68
Output for 7.0.14
467 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 467
Output for 7.0.10
779 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 779
Output for 7.0.9
469 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 469
Output for 7.0.8
512 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 512
Output for 7.0.7
522 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 522
Output for 7.0.6
880 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 880
Output for 7.0.5
11 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 11
Output for 7.0.4
20 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 20
Output for 7.0.3
332 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 332
Output for 7.0.2
273 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 273
Output for 7.0.1
560 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 560
Output for 7.0.0
500 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 500
Output for hhvm-3.12.0
426 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 426
Output for hhvm-3.10.0
960 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 960
Output for 5.6.28
883 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 883
Output for 5.6.25
866 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 866
Output for 5.6.24
647 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 647
Output for 5.6.23
297 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 297
Output for 5.4.34, 5.6.22
383 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 383
Output for 5.6.21
510 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 510
Output for 5.5.36, 5.6.20
432 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 432
Output for 5.6.19
589 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 589
Output for 5.6.18
14 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 14
Output for 5.6.17
425 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 425
Output for 5.6.16
207 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 207
Output for 5.6.15
728 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 728
Output for 5.6.14
250 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 250
Output for 5.4.39, 5.6.13
653 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 653
Output for 5.6.12
290 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 290
Output for 5.6.11
928 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 928
Output for 5.6.10
755 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 755
Output for 5.6.9
308 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 308
Output for 5.6.8
170 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 170
Output for 5.6.7
800 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 800
Output for 5.6.6
862 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 862
Output for 5.6.5
679 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 679
Output for 5.6.4
809 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 809
Output for 5.6.3
803 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 803
Output for 5.6.2
137 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 137
Output for 5.6.1
85 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 85
Output for 5.6.0
349 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 349
Output for 5.5.38
257 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 257
Output for 5.4.36, 5.5.37
715 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 715
Output for 5.5.35
402 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 402
Output for 5.5.34
986 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 986
Output for 5.5.33
996 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 996
Output for 5.5.32
150 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 150
Output for 5.5.31
767 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 767
Output for 5.4.40, 5.5.30
355 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 355
Output for 5.5.29
870 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 870
Output for 5.5.28
627 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 627
Output for 5.5.27
61 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 61
Output for 5.5.26
362 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 362
Output for 5.5.25
942 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 942
Output for 5.5.24
17 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 17
Output for 5.5.23
184 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 184
Output for 5.5.22
859 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 859
Output for 5.5.21
536 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 536
Output for 5.5.20
753 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 753
Output for 5.5.19
214 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 214
Output for 5.5.18
648 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 648
Output for 5.5.16
180 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 180
Output for 5.5.15
613 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 613
Output for 5.5.14
650 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 650
Output for 5.5.13
353 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 353
Output for 5.5.12
283 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 283
Output for 5.5.11
933 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 933
Output for 5.5.10
278 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 278
Output for 5.5.9
93 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 93
Output for 5.5.8
433 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 433
Output for 5.5.7
51 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 51
Output for 5.5.6
783 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 783
Output for 5.5.5
258 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 258
Output for 5.5.4
825 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 825
Output for 5.5.3
229 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 229
Output for 5.5.2
242 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 242
Output for 5.5.1
727 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 727
Output for 5.5.0
336 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 336
Output for 5.4.45
861 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 861
Output for 5.4.44
196 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 196
Output for 5.4.43
475 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 475
Output for 5.4.42
79 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 79
Output for 5.4.41
265 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 265
Output for 5.4.38
699 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 699
Output for 5.4.37
457 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 457
Output for 5.4.35
516 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 516
Output for 5.4.32
856 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 856
Output for 5.4.31
695 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 695
Output for 5.4.30
76 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 76
Output for 5.4.29
775 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 775
Output for 5.4.28
1 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 1
Output for 5.4.27
739 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 739
Output for 5.4.26
108 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 108
Output for 5.4.25
641 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 641
Output for 5.4.24
794 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 794
Output for 5.4.23
132 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 132
Output for 5.4.22
785 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 785
Output for 5.4.21
112 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 112
Output for 5.4.20
664 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 664
Output for 5.4.19
243 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 243
Output for 5.4.18
998 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 998
Output for 5.4.17
197 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 197
Output for 5.4.16
13 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 13
Output for 5.4.15
864 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 864
Output for 5.4.14
384 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 384
Output for 5.4.13
395 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 395
Output for 5.4.12
561 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 561
Output for 5.4.11
722 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 722
Output for 5.4.10
414 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 414
Output for 5.4.9
704 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 704
Output for 5.4.8
59 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 59
Output for 5.4.7
526 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 526
Output for 5.4.6
165 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 165
Output for 5.4.5
892 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 892
Output for 5.4.4
905 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 905
Output for 5.4.3
319 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 319
Output for 5.4.2
64 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 64
Output for 5.4.1
630 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 630
Output for 5.4.0
890 Notice: Undefined property: Singleton::$id in /in/uZQjP on line 19 890
Output for 5.3.29
126 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.28
876 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.27
1000 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.26
980 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.25
505 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.24
416 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.23
47 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.22
360 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.21
796 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.20
945 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.19
932 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.18
461 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.17
638 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.16
5 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.15
213 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.14
883 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.13
22 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.12
867 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.11
458 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.10
937 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.9
854 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.8
428 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.7
847 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.6
593 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.5
384 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.2, 5.3.4
515 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.3
673 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.1
186 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP on line 26
Process exited with code 255.
Output for 5.3.0
738 Fatal error: Call to undefined method Closure::bind() in /in/uZQjP 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/uZQjP 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/uZQjP 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/uZQjP 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/uZQjP 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/uZQjP on line 7
Process exited with code 255.