I need to call a dynamic function and send the current object as reference in the said function.
In PHP 5.3 this works, as opposed to PHP 5.4:
$value = call_user_func("MyFunction", $value, $row, $this,etc....); // using $this because this call happends inside an object
Where MyFunction is :
function MyFunction($value,&$row,&$column,&$grid,etc...){
...
}// myFunction is a standalone function, not inside any object
In PHP 5.4 I get the error "parameter expected to be a reference, value given". The respective error refers to the $this parameter at the call_user_func line. It seems that if I specify $this directly in the call it is considered as pass-by-value because if I do like this, it works:
$that = &$this;
$value = call_user_func("MyFunction", $value, $row, $that,etc....);
And I have to do this with all the other parameters which are related to the current object.
Question: is there any other - more elegant - way to do this ? Am I missing something?