3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php abstract class A{ static protected $shared = array(); static function create(){ if (isset(static::$shared['mailer'])){ return static::$shared['mailer']; } $mailer = new static(); //this is the correct way return static::$shared['mailer'] = $mailer; } } class B extends A{ } $obj=B::create(); $obj1=B::create(); var_dump($obj); var_dump($obj1);
based on kVWFV
Output for 5.6.0 - 7.3.0beta1
object(B)#1 (0) { } object(B)#1 (0) { }