controller的 _remap 似乎失效?
我在App\Controllers\wheels建立一支controller: care.php,简单测试_remap,代码如下,
假设网址为 127.0.0.1/myproject/wheels/care/a1,结果会出现 a1,
假设网址为 127.0.0.1/myproject/wheels/care/bb123,结果会出现 Method App\Controllers\wheels\Care::bb123() does not exis,
并没有如我预期导向contentProcess函式,
请教我哪边写错了呢? 谢谢
namespace App\Controllers\wheels;
use CodeIgniter\Controller;
class Care extends Controller {
public function _remap($method, ...$params) {
if (method_exists($this, $method)) {
return $this->$method();
}else{
return $this->contentProcess();
}
}
protected function contentProcess() {
echo 'contentProcess';
}
protected function a1() {
echo "a1";
}
}
本帖最后由 燃雲 于 2019-2-20 16:40 编辑
public function _remap($method, ...$params)
{
$method = 'process_'.$method;
if (method_exists($this, $method))
{
return $this->$method(...$params);
}
show_404();
}
谢谢你的协助,但这不是答案{:1_1:} rfrkk 发表于 2019-2-21 08:37
谢谢你的协助,但这不是答案
public function _remap($method, ...$params)
{
$method = 'process_'.$method;// <-这不是答案?
if (method_exists($this, $method))
{
return $this->$method(...$params);
}
show_404();
}
看起来没问题,更新一下 CI4 到最新版试试? 我發現問題是在 ci debug tool 的route.php
我打包成zip 下載點
https://drive.google.com/file/d/1odfEF8Pflvfxa0Fgsx05SwfGkibBoTDW/view
页:
[1]