Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- class A{
- protected static $instance = null;
- public static function getInstance(){
- if(self::$instance === null)
- self::$instance = new self();
- return self::$instance;
- }
- public function show($param){
- echo 'Show '.$param.chr(10);
- }
- public function __destruct(){
- echo 'Destruct '.__CLASS__.chr(10);
- }
- }
- class B extends Mysqli{
- public function __destruct(){
- A::getInstance()->show(__CLASS__);
- echo 'Destruct '.__CLASS__.chr(10);
- }
- }
- class C{
- protected static $class = null;
- public static function attachClass(&$class){
- self::$class = $class;
- }
- public function __destruct(){
- A::getInstance()->show(__CLASS__);
- echo 'Destruct '.__CLASS__.chr(10);
- }
- }
- $a = A::getInstance();
- $b = new B();
- $GLOBALS['d'] = $b;
- // or
- C::attachClass($b);
- $c = new C();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement