I tried to build a singleton class, but it doesn't work. The function i used do not return anything.
Code on Pastie.org (Hope it works)
<?php
//-----------------singleton class------------------------
final class SearchResult {
private static $instance = NULL;
private function __construct() {
}
public static function getInstance() {
if (self::$instance === NULL) {
self::$instance = new self;
}
return self::$instance;
}
public function getResultTable(){
return 'Test- Result';
}
}
// try to use the class
// [...]
function Test(){
$searchResult = SearchResult::getInstance();
return 'Result: '.$searchResult->getResultTable;
}
// [...]
?>