传递多个参数
在cakephp框架具体应用的过程中,我们会发现很多情况下传递一个参数已不能满足我们的需求,这就面临着多个参数传递问题。
在views下的ctp页面中:
方式一:
array('action' => '/edit_teacher_center/'.$id.'/'.$host_id);
方式二:
$html->link(' 编辑 ', array('url'=>'/departments/edit_department_center?id='.$id.'&host_id='.$hostid)).
也可写成:
$html->link(' 编辑 ', array('action'=>'edit_teacher_center',$id,$host_id)).
则在Controllers 中对应函数接收时: function edit_teacher_center ( $id, $host_id ){…}
注:拼串前,要保证$id,$host_id在对应的controllers中是set过的,值是可取到的。
近期本人开通了微信订阅号“CakePHP学习”,欢迎大家的关注。