Home > php教程 > PHP源码 > 获取提示:对象类型

获取提示:对象类型

PHP中文网
Release: 2016-05-25 17:11:07
Original
1367 people have browsed it


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);
Copy after login

                   

Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template