In php7 inherit properties and public protected private use

Three characteristics inherited PHP7 php are single inheritance, the subclass inherits the parent class, the base class, the following were used php7 public protected private talk

represents a global public, internal class can access external subclasses;
Private represented private, internal use only this class;
protected indicating protection, only this class or subclass or parent classes can be accessed;

class Person{

public $name=''96net.com.cn";
protected $age=17;
private $height=178;

public function look(){

echo '我是公共的';
}

protected function say(){
   echo '我是保护的';
}

private function money(){

   echo '我是私有的';
}

}

class Son{

public $name=''dc3688.com";
protected $age=17;
private $height=178;

public function liston(){

echo '我是公共的';
}

}

Subclasses inherit parent, child property attributes override the parent class, subclass methods parent :: parent class may be rewritten,

Guess you like

Origin blog.51cto.com/13959155/2458870