Skip to content

Instantly share code, notes, and snippets.

@amashigeseiji
Created April 6, 2013 00:10
Show Gist options
  • Save amashigeseiji/5323622 to your computer and use it in GitHub Desktop.
Save amashigeseiji/5323622 to your computer and use it in GitHub Desktop.
<?php
class Single
{
private static $instance;
private function __construct()
{
self::tetete();
}
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new Single;
}
return self::$instance;
}
public function tetete()
{
echo 'tetete';
}
}
$a = Single::getInstance();
$b = Single::getInstance();
if ( $a === $b )
{
echo 'true';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment