PHP Notice: Array to string conversion only on PHP 7
This should work with PHP 7:
class foo {
var $bar = 'I am bar.';
}
$foo = new foo();
$bar = 'bar';
$baz = array('foo', 'bar', 'baz', 'quux');
echo "{$foo->$bar}\n";
echo "{$foo->{$baz[1]}}\n";
This is caused because in PHP 5 the following line:
echo "{$foo->$baz[1]}\n";
is interpreted as:
echo "{$foo->{$baz[1]}}\n";
While in PHP 7 it's interpreted as:
echo "{{$foo->$baz}[1]}\n";
And so in PHP 7 it's passing the entire array to $foo
instead of just that element.