Changes

Jump to: navigation, search

Singleton

359 bytes added, 18:19, 8 March 2007
Sample Code
}
}
</pre>
Singleton pattern in PHP 5:
<pre>
<?php
class Singleton {
// object instance
static $instance;
private function __construct() {}
private function __clone() {}
public static function getInstance() {
if (!Singleton::$instance instanceof self) {
Singleton::$instance = new self();
}
return Singleton::$instance;
}
}
?>
</pre>
1
edit

Navigation menu