PHP 5: Non-static method | array_map
In PHP 4 if you wanted to get a callback from a class using the PHP function array_map for example, you could do the following:
array_map(array('MyClass', 'MyFunction'), $Param);
However if you are porting your scripts over to PHP 5 and developing in “E_STRICT”, the method will still work however you will get the following error:
PHP 5: Non-static method MyClass::MyFunction() cannot be called statically, assuming $this from compatible context MyClass
One method to fix this error in PHP5 is to make sure the function “MyFunction” is a static function. Example: static MyFunction() { }
However if you are coding a script that needs to work on PHP4 & PHP5 the above example will not work. So another alternative is to use the PHP function array_map like so:
array_map(array(&$this, 'MyFunction'), $Param);
















