初始代码 2018-11-24 12:54

代码内容:

<?php
header('Content-type:text/html;charset=utf-8');

class Animal{

	protected $name;
	private $age;
	private $color;

	public function __construct($name,$age,$color){
		$this->name=$name;
		$this->age=$age;
		$this->color=$color;
	}

	public function set_name($name){
		$this->name=$name;
	}

	public function set_age($age){
		$this->age=$age;
	}

	public function set_color($color){
		$this->color=$color;
	}

	// 接口
	public function get_name(){
		return $this->name;
	}

	// 接口
	public function get_age(){
		return $this->age;
	}

	// 接口
	public function get_color(){
		return $this->color;
	}

	public function show(){
		echo "名字:{$this->name}<br />";
		echo "年龄:{$this->age}岁<br />";
		echo "颜色:{$this->color}<br />";
	}

}