<?php
    class Car{
        protected $_color;
        protected $_model;

        public function __call($name,$arguments){
            $first=isset($arguments[0]) ? $arguments[0] : null;
            switch ($name) {
                case 'getColor':
                    return $this->_color;
                case 'setColor':
                    $this->_color=$first;
                    return $this;
                case 'getModel':
                    return $this->_model;
                case 'setModel':
                    $this->_model=$first;
                    return $this;
            }
        }
    }
    $car=new Car();
    $car->setColor("blue")->setModel("b-class");
    echo $car->getModel();
?>

 

相关文章:

  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
  • 2021-12-02
  • 2021-09-25
  • 2021-07-23
  • 2022-12-23
猜你喜欢
  • 2021-09-11
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
  • 2021-05-30
  • 2021-10-24
相关资源
相似解决方案