class
<?php class Test{ protected $parameters=array(); /** * @return array */ public function getParameters() { return $this->parameters; } /** * @param string $key * @return mixed */ public function getParameter($key) { return $this->parameters[$key]; } /** * @param string $key * @param mixed $value * @return $this */ public function setParameter($key, $value) { $this->parameters[$key]= $value; return $this; } /** * @param $value * * @return $this */ public function setName($value) { return $this->setParameter('name', $value); } } $test=new Test(); $test->setParameter('age',20); $test->setParameter('name','lilei'); $test->setName('张三'); $name=$test->getParameter('name'); $params=$test->getParameters(); var_dump($name); var_dump($params);