Created
June 23, 2011 04:22
-
-
Save tjlytle/1041899 to your computer and use it in GitHub Desktop.
Example singleton
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Singleton | |
{ | |
public static function getInstance() | |
{ | |
static $instance; | |
if(empty($instance)){ | |
$class = get_called_class(); | |
$instance = new $class; | |
} | |
return $instance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment