02-02-2009, 01:14 PM
|
#1 (permalink)
|
|
The Contributor
Join Date: Feb 2009
Posts: 28
Thanks: 10
|
help with object code
hi I was reading php manual on object and classes and came across this code. i have no idea what this code is doing. i tried to figure it out but could not get anything from it.
PHP Code:
<?php
class db {
//...
private static $instance;
//...
public static function singleton() {
if(!isset(self::$instance)) {
// what is the purpose of following two lines
$c = __CLASS__;
self::$instance = new $c();
// End of lines
}
return self::$instance;
}
//...
}
?>
the bold text is the main issue. could anybody please explain what this chunk of code is doing.
Thanks
|
|
|
|