private 的访问问题
<?php
class Car{
private $price = '1000';
public function getPrice() {
return $this->price; //内部访问私有属性
}
$car = new Car();
//在这里输出$car对象的name属性
echo $car->getPrice();
<?php
class Car{
private $price = '1000';
public function getPrice() {
return $this->price; //内部访问私有属性
}
$car = new Car();
//在这里输出$car对象的name属性
echo $car->getPrice();
2015-08-23
举报