PHPでのシングルトンパターンとか
PHPでのシングルトンパターン
[php]
<?php
class Klass { private function __construct() { } static function getInstance() { static $obj = null; return $obj ? $obj : $obj = new self; // 5.3以降なら return $obj ?: $obj = new self; } }
Klass::getInstance();[/php]
おお。シンプル。