Welcome Guest, Not a member yet? Register   Sign In
controller of _remap seem to fail.
#1
Exclamation 

I build a controller: care.php in App\Controllers\wheels,
for simple testing _remap, the code is as follows.

Assuming the URL is 127.0.0.1/myproject/wheels/care/a1, it will get a1 string.
But,assuming the URL is 127.0.0.1/myproject/wheels/care/bb123, the result will appear "Method App\Controllers\wheels\Care::bb123() does not exis",
it is not as directed to the contentProcess function as I expected,
Please give me help.

PHP Code:
namespace App\Controllers\wheels;
 
use 
CodeIgniter\Controller;
 
class 
Care extends Controller {
 
 
   public function _remap($method, ...$params) {
 
       if (method_exists($this$method)) {
 
           return $this->$method(); // go to a1
 
       }else{
 
            return $this->contentProcess();//go to contrntProcess
 
       }
 
   }
 
 
   protected function contentProcess() {
 
       echo 'contentProcess';
 
   }
 
 
   protected function a1() {
 
       echo "a1";
 
   }
 

Reply


Messages In This Thread
controller of _remap seem to fail. - by rfrkk - 02-20-2019, 06:01 PM
RE: controller of _remap seem to fail. - by rfrkk - 02-20-2019, 09:46 PM
RE: controller of _remap seem to fail. - by rfrkk - 02-20-2019, 09:48 PM
RE: controller of _remap seem to fail. - by rfrkk - 02-21-2019, 10:42 PM
RE: controller of _remap seem to fail. - by rfrkk - 02-22-2019, 06:19 PM
RE: controller of _remap seem to fail. - by rfrkk - 03-02-2019, 06:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB