Convert array to string in php7

I am trying to execute this code (it worked on php5, now I am on php7):

$this->links->$data[$te]['attributes']['ID'] = $data[$te]['attributes']['URL'];

But I get this error:

ContextErrorException: Note: converting an array to a string

Thank you in advance

+6
source share
1 answer

It depends on how complex variables are allowed in PHP 5 vs. 7. See Changes to Variable Processing section here: http://php.net/manual/en/migration70.incompatible.php

The difference is that the expression:

$this->links->$data[$te]['attributes']['ID']

evaluated as follows in PHP 5:

$this->links->{$data[$te]['attributes']['ID']}

and so on PHP 7:

($this->links->$data)[$te]['attributes']['ID']

See https://3v4l.org/gB0rQ for a cut out example.

, , {}, , . , , PHP 5, , , PHP.

+7

All Articles