soltice wrote in php

Singleton

I'm trying to create a singleton class, but when I try the following code, it seems to create two instances instead of one..


class tessy{
	function tessy(){
		echo "tell it to queen doppelpopolis!";
	}

	function getInstance(){
		static $instance;
		
		if(!isset($instance)){
			$instance =& new tessy();
		}
		
		return $instance;
	}
}

tessy::getInstance();
tessy::getInstance();