Singleton getInstance() not working (PHP4)
Posted: Sun Feb 27, 2005 12:03 pm
Hello, my server has PHP4, so I have to use strange hacks to do useful stuff with objects...
Since PHP4 doesn't support static class variables, this is what I had:
It always returns an object, but not the same object. It returns a new object every time.
I tried !is_object($results), too... am I missing something dumb?
- Monkey
Since PHP4 doesn't support static class variables, this is what I had:
Code: Select all
function get_results()
{
static $results = false;
if ( $results === false )
{
$results = new DB_Results;
}
return $results;
}I tried !is_object($results), too... am I missing something dumb?
- Monkey