Can't call static method from class as variable name?

andros1245

New Member
I'm using php 5.2.6. I have a strategy pattern, and the strategies have a static method. In the class that actually implements one of the strategies, it gets the name of the strategy class to instantiate. However, I wanted to call one of the static methods before instantiation, like this:\[code\]$strNameOfStrategyClass::staticMethod();\[/code\]but it gives \[code\]T_PAAMAYIM_NEKUDOTAYIM\[/code\].\[code\]$> cat test.php<?interface strategyInterface { public function execute(); public function getLog(); public static function getFormatString();}class strategyA implements strategyInterface { public function execute() {} public function getLog() {} public static function getFormatString() {}}class strategyB implements strategyInterface { public function execute() {} public function getLog() {} public static function getFormatString() {}}class implementation { public function __construct( strategyInterface $strategy ) { $strFormat = $strategy::getFormatString(); }}$objImplementation = & new implementation("strategyB") ;$> php test.phpParse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /var/www/test.php on line 24$> php -vPHP 5.2.6-1+lenny9 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 4 2010 03:25:57)\[/code\]Would this work in 5.3?
 
Back
Top