Singleton

<?php

class Singleton{
 private static $init = '';

 private function __construct()
 {

 }

 public static function getInstance()
 {
   if(self::$init == null){
     self::$init = new self;
   }
   return self::$init;
 }

 public function hello()
 {
   echo('hello'."\n");
 }
}

$s = Singleton::getInstance();
$s->hello();

インスタンスの生成を一度だけ行う。
二度目は生成済みのオブジェクトを返す。