Home  >  Article  >  php教程  >  获取提示:对象类型

获取提示:对象类型

PHP中文网
PHP中文网Original
2016-05-25 17:11:071336browse


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

                   

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn