3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public $id; public static function byId($id) { self::__construct($id); } private function construct($id) { $this->id = $id; } } $a = A::byId(5); var_dump($a->id);
based on N0qGJ
Output for 7.0.0 - 7.3.0rc3
Fatal error: Uncaught Error: Cannot call constructor in /in/DZlGe:8 Stack trace: #0 /in/DZlGe(16): A::byId(5) #1 {main} thrown in /in/DZlGe on line 8
Process exited with code 255.
Output for 5.6.0 - 5.6.26
Fatal error: Cannot call constructor in /in/DZlGe on line 8
Process exited with code 255.