I am a newbie of PHP. I study it from php.net
, but I found a problem today.
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";
The documentation(http://php.net/manual/en/language.types.string.php) say that the above example will output:
I am bar.
I am bar.
But I get the different output run on my PC(PHP 7):
I am bar.
<b>Notice</b>: Array to string conversion in ... on line <b>9</b><br />
<b>Notice</b>: Undefined property: foo::$Array in ... on line <b>9</b><br />
Why?