public function __call($name,$args){
if($name=='speedDown'){
$this->speed-=10;
}
}
if($name=='speedDown'){
$this->speed-=10;
}
}
2017-07-13
class Truck extends Car{
public function speedUp(){
parent::speedUp();
$this->speed+=50;
return $this->speed;
}
}
public function speedUp(){
parent::speedUp();
$this->speed+=50;
return $this->speed;
}
}
2017-07-13
<?php
//分隔字符串
$str = 'sun-moon-star';
$array=explode("-",$str);
foreach($array as $key =>$a){
echo $a;
}
?>
//分隔字符串
$str = 'sun-moon-star';
$array=explode("-",$str);
foreach($array as $key =>$a){
echo $a;
}
?>
2017-07-12
$str = preg_replace('/(\w+.\w+)/','<em>$1</em>',$str);
2017-07-12
class Run{
public static function say1(){
return 1;
}
public static function say2(){
return 2;
}
public static function say3(){
return 3;
}
}
echo Run::say1()."<br>";
echo Run::say2()."<br>";
$three = 'say3';
$className = 'Run';
echo $className::$three();
public static function say1(){
return 1;
}
public static function say2(){
return 2;
}
public static function say3(){
return 3;
}
}
echo Run::say1()."<br>";
echo Run::say2()."<br>";
$three = 'say3';
$className = 'Run';
echo $className::$three();
2017-07-12
class Car{
//在这里定义一个共有属性name
public $name='aaa';
}
$car = new Car();
//在这里输出$car对象的name属性
echo $car->name;
//在这里定义一个共有属性name
public $name='aaa';
}
$car = new Car();
//在这里输出$car对象的name属性
echo $car->name;
2017-07-12
<?php
//定义一个Car类并实例化一个对象
class Car{
public $name='汽车';
public function getName(){
$car=new car();
return $this->name;
}
}
//定义一个Car类并实例化一个对象
class Car{
public $name='汽车';
public function getName(){
$car=new car();
return $this->name;
}
}
2017-07-12