美元符号在PHP中的含义是什么?我有这样的代码:美元符号在PHP中的含义是什么?
<?php
class Building {
public $number_of_floors = 5;
private $color;
public function __construct($paint) {
$this->color = $paint;
}
public function describe() {
printf('This building has %d floors. It is %s in color.',
$this->number_of_floors,
$this->color
);
}
}
$bldgA = new Building('red');
$bldgA->describe();
?>
看来,$
表示像变量:
$number_of_floors
$color
但我感到困惑,当我看到以下内容:
$bldgA->describe();
$bldgA->number_of_floors;
为什么没有这些变量前的美元符号?
嗯,也许该再次阅读[PHP语言参考](http://php.net/manual/en/langref.php)... –
谷歌和阅读PHP OOP的基础知识。 – Sarfraz
http://www.php.net/manual/en/language.oop5.basic.php – JJJ