1

I developed an application in CakePHP - Windows.

Then I put it in Ubuntu and made the necessary settings. Everything works except the line:

$this-> set (
    'projeto_id', 
    $this-> requestAction (
        "/Projects/getprojectsofcategory", 
        array (
            'setor_id' => $this->Registration-> read()['Registration']['setor_id'] 
        )
    )
);

gives me the following error:

Fatal Error Error: syntax error, unexpected '[', expecting ')'

and I do not understand why. If I comment out the line gives the following error because it is of the same genre.

Can someone explain me why this error?

  • You have an older version of PHP in Ubuntu that doesn't support accessing array elements directly from the method return value. Why space between `$ this`? I didn't know that was even valid. – JJJ Jun 26 '13 at 20:41
  • i'm sorry. doesnt exist any space between $ this :) –  Jun 26 '13 at 20:43
  • It's generally best to show the *actual* code you have when asking questions. – JJJ Jun 26 '13 at 20:44
  • so, should i install the latest version of php? I'm not going to try now, I do not know what version of php that is installed, but I think it will be the latest :/ –  Jun 26 '13 at 20:45

1 Answers1

5

You'll need to upgrade to a newer version of PHP, or you'll have to change your functions.

Check the most voted answer of this post. $this->Registration->read()['Registration'] is not posible for PHP < 5.4

If you can not upgrade php, you'll need to have an intermediary variable

$valueRead = this->Registration->read();

$this-> set (
'projeto_id', 
$this-> requestAction (
    "/Projects/getprojectsofcategory", 
    array (
        'setor_id' => $valueRed['Registration']['setor_id'] 
    )
)
);
Community
  • 1
  • 1
Nunser
  • 4,512
  • 8
  • 25
  • 37