類和對象這點看不懂
<?php
//定義一個類
class Car {
? ? var $name = '汽車1111';
? ? function getName() {
? ? ? ? echo $this->name;
? ? ? ? return $this->name;
? ? }
}
//實例化一個car對象
$car = new Car();
$car->getName();
執行完以后結果是:汽車1111,看是我看不懂的是為什么這樣寫
echo $this->name;
return $this->name;
而不是
echo $this->$name;
return $this->$name;
上面等一的時候,name是有$符號的,為什么引用的時候就沒了,而且執行完以后,結果還正確,懵了
2016-07-14
固定寫法 記住熟悉就行了