thinkphp5 学习记录 2019-11-27

  • URL 传参
    不带参方法:http://localhost/admin/person/eat/
    带参访问1:http://localhost/admin/person/eat/food/meat/drink/water
    带参访问2:http://localhost/admin/person/eat?food=apple&drink=water
解释:admin 模块;person 控制器; eat 方法;

参数之和名称有关系,和顺序无关, key/value 会自动匹配

class Person{
  //egg  milk 默认值,不传就会用默认值赋值
    public function eat($food = 'egg',$drink = 'milk'){
        return ('u plan to eat food='. $food  . ' add ' . 'drink = '. $drink);
    }

}

打印:u plan to eat food=apple add drink = water

你可能感兴趣的:(thinkphp5 学习记录 2019-11-27)