-
-
Save Div-Man/9f710b9657873d6fbc2a06f537b4b7e8 to your computer and use it in GitHub Desktop.
Php Singleton example
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 Mysingleton | |
{ | |
private static $instance; | |
private function __construct() | |
{} | |
public static function getInstance() | |
{ | |
if ( self::$instance == NULL ) | |
{ | |
self::$instance = new Mysingleton; | |
} | |
return self::$instance; | |
} | |
public function k() | |
{ | |
echo 'Accessing Through Singleton'; | |
} | |
} | |
#$k = Mysingleton::getInstance(); | |
#$k->k(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment