首页  >  文章  >  php教程  >  获取提示:对象类型

获取提示:对象类型

PHP中文网
PHP中文网原创
2016-05-25 17:11:071336浏览


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);

                   

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn