- var_dump: documentation ( source)
<?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);