- class User{
- public function __construct($name,$sex,$height){
- $this->name=$name;
- $this->sex=$sex;
- $this->height=$height;
- }
- public function show(){
- echo "姓名:".$this->name." 性别:".$this->sex;
- }
- }
- class Book{
- public function __construct($author,$prince,$public){
- $this->author=$author;
- $this->prince=$prince;
- $this->public=$public;
- }
- public function show(){
- echo "作者:".$this->author." 发布:".$this->public;
- }
- }
- class UserAdmin{
- public static function changeName(Book $name){
- $name->show();
- }
- }
- $user = new User("黎明","男","170");
- UserAdmin::changeName($user);
- //该片段来自于http://www.codesnippet.cn/detail/270520133598.html
来源: http://www.codesnippet.cn/detail/270520133598.html