I have the following:
class HP_Utils {
/**********************************************************************/
public static function getAction()
/**********************************************************************/
{
if( isset( $_GET[ 'action' ] ) ) {
return $_GET[ 'action' ];
}
else if ( isset( $_POST[ 'action' ] )) {
return $_POST[ 'action' ];
}
}
/**********************************************************************/
}
Then in other class:
$this->utils = $this->load( 'helper', 'Utils' );
$action = $this->utils::getAction(); <============== ERROR
The loader:
abstract class MController {
/**********************************************************************/
protected function load( $type, $className ) {
switch( $type ) {
case 'model':
$name = 'MD_' . $className;
break;
case 'view':
$name = 'VW_' . $className;
break;
case 'helper';
$name = 'HP_' . $className;
break;
}
$path = $type . '/' . $name . '.php';
include( $path );
return new $name;
}
Gives me error:
PHP Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) in /home/jorgee/www/menu/controller/CT_Menu.php on line 11
Obviously i'm badly accesing the static method but I thought that was the way, any help?
ClassName::methodName()
.$this->util->getAction();
(which is perfectly ok even though it's a static, it can also be called as an instance method)A property declared as static can not be accessed with an instantiated class object (**though a static method can**).
No mention there of an impending deprecation of that functionality.