不写public不是默认public么?为什么会报错呢?
<?php
class Car {
public $speed = 10;
//在这里使用重载实现speedDown方法
function __call($name,$args){
if($name=='speedDown'){
$this->speed-=10;
}
}
}
$car = new Car();
$car->speedDown(); //调用不存在的speedDown方法
echo $car->speed;
<?php
class Car {
public $speed = 10;
//在这里使用重载实现speedDown方法
function __call($name,$args){
if($name=='speedDown'){
$this->speed-=10;
}
}
}
$car = new Car();
$car->speedDown(); //调用不存在的speedDown方法
echo $car->speed;
2019-01-07
举报