php类,构造函数 静态变量实例

PHP实例代码如下:

  1. class dispatcher{
  2. private $config;
  3. public static $o;
  4. function __construct(){
  5. echo 'sss';
  6. }
  7. public static function getinstance(){
  8. if (!self::$o){
  9. self::$o = new dispatcher();
  10. }
  11. self::$o;
  12. }
  13. }
  14. new dispatcher();