Question about Strings
Posted: Sun Dec 11, 2011 1:17 pm
Hey, I'm not quite understanding why the last line of this code
outputs I am bar. Why doesn't it output just "bar."
Code: Select all
echo "{$foo->$baz[1]}\n";Code: Select all
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>the Good, the Loud, & the Angry</title>
</head>
<body>
<?php
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";
?>
</body>
</html>