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(); $singy2->doAction();
Output for 7.1.0
968968
Output for 7.0.14
807807
Output for 7.0.12
375375
Output for 7.0.6
879879
Output for 7.0.5
148148
Output for 5.4.25, 7.0.4
740740
Output for 7.0.3
492492
Output for 7.0.2
161161
Output for 7.0.1
706706
Output for 5.5.21, 7.0.0
679679
Output for hhvm-3.12.0
414414
Output for 5.3.18, hhvm-3.10.0
775775
Output for 5.6.28
541541
Output for 5.6.21
635635
Output for 5.6.20
146146
Output for 5.6.19
658658
Output for 5.6.18
297297
Output for 5.6.17
696696
Output for 5.6.16
949949
Output for 5.6.15
959959
Output for 5.6.14
435435
Output for 5.6.13
254254
Output for 5.3.23, 5.6.12
497497
Output for 5.6.11
233233
Output for 5.6.10
539539
Output for 5.6.9
6666
Output for 5.1.6, 5.6.8
3636
Output for 5.6.7
719719
Output for 5.6.6
829829
Output for 5.5.10, 5.6.5
848848
Output for 5.6.4
349349
Output for 5.6.3
592592
Output for 5.6.2
511511
Output for 5.6.1
781781
Output for 5.2.1, 5.6.0
558558
Output for 5.5.35
771771
Output for 5.5.34
242242
Output for 5.5.33
512512
Output for 5.5.32
728728
Output for 5.5.31
599599
Output for 5.5.30
108108
Output for 5.5.29
800800
Output for 5.5.28
9898
Output for 5.5.27
612612
Output for 5.5.26
464464
Output for 5.5.25
852852
Output for 5.5.24
365365
Output for 5.5.23
947947
Output for 5.5.22
651651
Output for 5.5.20
115115
Output for 5.5.19
584584
Output for 5.5.18
825825
Output for 5.5.16
812812
Output for 5.5.15
978978
Output for 5.3.16, 5.5.14
290290
Output for 5.5.13
265265
Output for 5.5.12
733733
Output for 5.5.11
529529
Output for 5.5.9
491491
Output for 5.5.8
824824
Output for 5.5.7
513513
Output for 5.5.6
560560
Output for 5.5.5
339339
Output for 5.4.5, 5.5.4
273273
Output for 5.5.3
301301
Output for 5.5.2
167167
Output for 5.5.1
231231
Output for 5.5.0
650650
Output for 5.4.45
624624
Output for 5.4.44
932932
Output for 5.4.43
373373
Output for 5.4.42
729729
Output for 5.4.41
412412
Output for 5.4.40
818818
Output for 5.4.39
556556
Output for 5.4.38
439439
Output for 5.4.37
33
Output for 5.4.4, 5.4.36
381381
Output for 5.4.35
368368
Output for 5.3.9, 5.4.34
105105
Output for 5.4.32
883883
Output for 5.4.31
834834
Output for 5.4.30
691691
Output for 5.4.29
107107
Output for 5.4.28
139139
Output for 5.4.27
908908
Output for 5.4.26
713713
Output for 5.4.24
6262
Output for 5.4.23
379379
Output for 5.4.22
842842
Output for 5.4.21
791791
Output for 5.4.20
113113
Output for 5.4.19
55
Output for 5.0.1, 5.4.18
123123
Output for 5.4.17
591591
Output for 5.2.4, 5.4.16
180180
Output for 5.4.15
338338
Output for 5.0.0, 5.4.14
8585
Output for 5.4.13
644644
Output for 5.4.12
333333
Output for 5.4.11
981981
Output for 5.4.10
836836
Output for 5.4.9
310310
Output for 5.4.8
935935
Output for 5.4.7
319319
Output for 5.4.6
779779
Output for 5.4.3
3939
Output for 5.4.2
450450
Output for 5.4.1
192192
Output for 5.4.0
295295
Output for 5.3.29
869869
Output for 5.3.28
922922
Output for 5.3.27
505505
Output for 5.3.26
226226
Output for 5.3.25
951951
Output for 5.3.24
799799
Output for 5.3.22
2727
Output for 5.3.21
579579
Output for 5.3.20
699699
Output for 5.3.19
196196
Output for 5.3.17
157157
Output for 5.3.15
307307
Output for 5.3.14
573573
Output for 5.3.13
479479
Output for 5.3.12
572572
Output for 5.3.11
436436
Output for 5.3.10
710710
Output for 5.3.8
925925
Output for 5.3.7
6060
Output for 5.3.6
455455
Output for 5.3.5
171171
Output for 5.3.4
423423
Output for 5.3.3
643643
Output for 5.3.2
765765
Output for 5.3.1
316316
Output for 5.3.0
915915
Output for 5.2.7, 5.2.17
950950
Output for 5.2.16
403403
Output for 5.2.15
1515
Output for 5.2.14
429429
Output for 5.2.13
821821
Output for 5.2.12
862862
Output for 5.2.11
519519
Output for 5.2.10
585585
Output for 5.2.9
942942
Output for 5.2.8
238238
Output for 5.2.6
661661
Output for 5.2.5
460460
Output for 5.2.3
447447
Output for 5.2.2
755755
Output for 5.2.0
1313
Output for 5.1.5
826826
Output for 5.1.4
229229
Output for 5.1.3
222222
Output for 5.1.2
587587
Output for 5.1.1
811811
Output for 5.1.0
783783
Output for 5.0.5
122122
Output for 5.0.4
126126
Output for 5.0.3
7575
Output for 5.0.2
896896
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/1bfsc</b> on line <b>7</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/1bfsc</b> on line <b>7</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <b>/in/1bfsc</b> on line <b>7</b><br />
Process exited with code 255.