3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class myModel { public static function all() { return 1; } } class myClass { public $models; public $results; public function __construct() { $this->models->myModel = new myModel; $this->results = $this->models::all(); } } $result = (new myClass)->results; echo $result;
based on qaH85
Output for 7.0.0 - 7.2.0
Warning: Creating default object from empty value in /in/DN2XC on line 17 Fatal error: Uncaught Error: Call to undefined method stdClass::all() in /in/DN2XC:18 Stack trace: #0 /in/DN2XC(22): myClass->__construct() #1 {main} thrown in /in/DN2XC on line 18
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) in /in/DN2XC on line 18
Process exited with code 255.