<?php
class Counter {
var $counter = 0;
function increment_and_print()
{
print ++$this->counter;
print "\n";
}
}
class SingletonCounter {
static $m_instance = NULL; // throwing error here
function Instance()
{
if (self::$m_instance == NULL) {
self::$m_instance = new Counter();
}
return self::$m_instance;
}
}
SingletonCounter::Instance()->increment_and_print();
SingletonCounter::Instance()->increment_and_print();
SingletonCounter::Instance()->increment_and_print();
?>
is throwing the following error
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or
`'}'' in /singleton.php on line 15