0

I change with cakephp 3.2 to a new server and this server is running php 7 instead of 5.4. Now I have an issue with my interactive way of calling an component and the needed action. What I was using is the following:

$data[$csvKnowField->field_number] = $this->Replace->$csvKnowField['imports_mapping']['component_action']($data[$csvKnowField->field_number]);  

This is giving the error: Function name must be a string. As far as I can see the problem is coming from the action called because if I change it to:

$data[$csvKnowField->field_number] = $this->Replace->replaceComma($data[$csvKnowField->field_number]);   

everything works fine. The variable $csvKnowField['imports_mapping']['component_action'] is holding an interactive value so the different actions can be called in the Replace component, so it would be great to keep it that way.

Is there somebody how knows an solution so the the value in the variable can be used as an interactive way?

  • http://stackoverflow.com/questions/11706528/php-fatal-error-function-name-must-be-a-string-in – Deep Kakkar Mar 11 '16 at 13:52
  • I would suggest that you check out the PHP 7 migration guide, specifically **http://php.net/manual/de/migration70.incompatible.php#migration70.incompatible.variable-handling.indirect**, but generally you should read all of it. Also **http://stackoverflow.com/questions/9257505/dynamic-variable-names-in-php/35772533#35772533**. – ndm Mar 11 '16 at 13:57
  • Thanks, this led me to the solution. The following is working as espected $data[$csvKnowField->field_number] = $this->Replace->{$csvKnowField['imports_mapping']['component_action']}($data[$csvKnowField->field_number]); – Dennis van der Graaf Mar 11 '16 at 17:24

0 Answers0