3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class hell { private $ruler = 'devil'; function cry(){ echo $this->ruler; } } $inst = new hell(); $inst->cry(); $in2 = Closure::bind(function () {$this->ruler = 'jesus';}, $inst, get_class($inst)); $in2(); $inst->cry(); 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; } } Singleton::getInstance()->doAction(); // Применение $singy = Singleton::getInstance();
Output for 7.1.0
deviljesus748
Output for 5.4.19, 7.0.14
deviljesus169
Output for 7.0.10
deviljesus619
Output for 7.0.9
deviljesus270
Output for 7.0.8
deviljesus325
Output for 7.0.7
deviljesus880
Output for 7.0.6
deviljesus334
Output for 7.0.5
deviljesus422
Output for 7.0.4
deviljesus721
Output for 7.0.3
deviljesus863
Output for 7.0.2
deviljesus211
Output for 7.0.1
deviljesus699
Output for 7.0.0
deviljesus440
Output for hhvm-3.12.0
deviljesus38
Output for hhvm-3.10.0
deviljesus750
Output for 5.6.28
deviljesus766
Output for 5.6.25
deviljesus877
Output for 5.6.24
deviljesus571
Output for 5.6.23
deviljesus459
Output for 5.6.22
deviljesus803
Output for 5.6.21
deviljesus948
Output for 5.6.20
deviljesus84
Output for 5.6.19
deviljesus282
Output for 5.6.18
deviljesus256
Output for 5.6.17
deviljesus520
Output for 5.6.16
deviljesus976
Output for 5.6.15
deviljesus902
Output for 5.6.14
deviljesus649
Output for 5.6.13
deviljesus484
Output for 5.6.12
deviljesus104
Output for 5.6.11
deviljesus18
Output for 5.6.10
deviljesus592
Output for 5.6.9
deviljesus806
Output for 5.6.8
deviljesus194
Output for 5.6.7
deviljesus293
Output for 5.6.6
deviljesus22
Output for 5.6.5
deviljesus986
Output for 5.6.4
deviljesus42
Output for 5.6.3
deviljesus448
Output for 5.6.2
deviljesus674
Output for 5.6.1
deviljesus258
Output for 5.6.0
deviljesus544
Output for 5.5.38
deviljesus661
Output for 5.5.37
deviljesus458
Output for 5.5.36
deviljesus434
Output for 5.5.35
deviljesus731
Output for 5.5.34
deviljesus290
Output for 5.5.33
deviljesus237
Output for 5.5.32
deviljesus855
Output for 5.5.31
deviljesus465
Output for 5.5.30
deviljesus912
Output for 5.5.29
deviljesus608
Output for 5.5.28
deviljesus274
Output for 5.5.27
deviljesus735
Output for 5.5.26
deviljesus339
Output for 5.5.25
deviljesus17
Output for 5.5.24
deviljesus391
Output for 5.5.23
deviljesus265
Output for 5.5.22
deviljesus937
Output for 5.5.21
deviljesus199
Output for 5.5.20
deviljesus139
Output for 5.5.19
deviljesus494
Output for 5.5.18
deviljesus994
Output for 5.5.16
deviljesus501
Output for 5.5.15
deviljesus922
Output for 5.5.14
deviljesus601
Output for 5.5.13
deviljesus358
Output for 5.5.12
deviljesus572
Output for 5.5.11
deviljesus189
Output for 5.5.10
deviljesus7
Output for 5.5.9
deviljesus920
Output for 5.5.8
deviljesus596
Output for 5.5.7
deviljesus512
Output for 5.5.6
deviljesus207
Output for 5.5.5
deviljesus234
Output for 5.5.4
deviljesus322
Output for 5.5.3
deviljesus980
Output for 5.5.2
deviljesus438
Output for 5.5.1
deviljesus781
Output for 5.5.0
deviljesus97
Output for 5.4.45
deviljesus111
Output for 5.4.44
deviljesus774
Output for 5.4.43
deviljesus416
Output for 5.4.42
deviljesus382
Output for 5.4.41
deviljesus998
Output for 5.4.40
deviljesus312
Output for 5.4.39
deviljesus187
Output for 5.4.38
deviljesus240
Output for 5.4.37
deviljesus514
Output for 5.4.36
deviljesus906
Output for 5.4.35
deviljesus394
Output for 5.4.34
deviljesus303
Output for 5.4.32
deviljesus247
Output for 5.4.31
deviljesus5
Output for 5.4.30
deviljesus702
Output for 5.4.29
deviljesus226
Output for 5.4.28
deviljesus962
Output for 5.4.27
deviljesus161
Output for 5.4.26
deviljesus505
Output for 5.4.25
deviljesus755
Output for 5.4.24
deviljesus287
Output for 5.4.23
deviljesus75
Output for 5.4.22
deviljesus486
Output for 5.4.21
deviljesus784
Output for 5.4.20
deviljesus593
Output for 5.4.18
deviljesus266
Output for 5.4.17
deviljesus435
Output for 5.4.16
deviljesus145
Output for 5.4.15
deviljesus179
Output for 5.4.14
deviljesus630
Output for 5.4.13
deviljesus54
Output for 5.4.12
deviljesus142
Output for 5.4.11
deviljesus324
Output for 5.4.10
deviljesus839
Output for 5.4.9
deviljesus639
Output for 5.4.8
deviljesus606
Output for 5.4.7
deviljesus493
Output for 5.4.6
deviljesus802
Output for 5.4.5
deviljesus538
Output for 5.4.4
deviljesus136
Output for 5.4.3
deviljesus701
Output for 5.4.2
deviljesus148
Output for 5.4.1
deviljesus243
Output for 5.4.0
deviljesus495
Output for 5.3.0 - 5.3.29
devil Fatal error: Call to undefined method Closure::bind() in /in/shaCg on line 15
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/shaCg on line 15
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/shaCg on line 15
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/shaCg on line 4
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/shaCg on line 4
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/shaCg on line 4
Process exited with code 255.