欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

获取提示:对象类型

程序员文章站 2022-04-19 13:02:30
...
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);