当前位置:Gxlcms > PHP教程 > PHP类(初学)

PHP类(初学)

时间:2021-07-01 10:21:17 帮助过:20人阅读

类示例:Cat.php

name=func_get_arg(0);			$this->age=func_get_arg(1);			$this->color=func_get_arg(2);		}			}/* 不支持	 * function __construct($name,$age,$color)	{		$this->name=$name;		$this->age=$age;		$this->color=$color;	} */			public function  getName()	{		return $this->name;	}		public function setName($name)	{		return $this->name=$name;	}			public function getAge()	{		return $this->age;	}	public function setAge($age)	{		$this->age=$age;	}		public function getColor()	{		return $this->color;	}	public function setColor($color)	{		$this->color=$color;	}	}?>

对象:

setName('蔡倩倩');$cat1->setAge(24);$cat1->setColor('白的'); */echo 'Cat1的姓名为:'.$cat1->getName().'
年龄为:'.$cat1->getAge();?>

人气教程排行