Created
April 6, 2013 00:10
-
-
Save amashigeseiji/5323622 to your computer and use it in GitHub Desktop.
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 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