Home > Backend Development > PHP Tutorial > 一段代码不明白,求解,多谢

一段代码不明白,求解,多谢

WBOY
Release: 2016-06-13 12:31:19
Original
817 people have browsed it

一段代码不明白,求解,谢谢
一段代码不明白,求解,谢谢
如下代码
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";
?>

输出结果:
I am bar. I am bar. 
问1: 在程序中,已经使用了 \n换行,为什么输出的结果内,没有换行,而是做一行的
问2: {$foo->$bar} 输出的是类foo里的变量bar  这个理解的
     {$foo->$baz[1]} 这段不理解,为什么也输出了 I am bar ,类foo内不包含有baz,求解
谢谢!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template