codeigniter URI路由问题:输出为$1,而不是名称


codeigniter URI routing issue: output as $1 rather than the name

我正在努力实现这样的目标:

example.com/profile/abc

但是下面的代码给出了如下输出$1而不是配置文件名称。例如,这里变量$name的输出应该是abc,但输出是1

控制器

class Profile extends CI_Controller
{
   public function get_profile($name)
   {
    echo $name;
   }
}

Routes.php

$route['profile/:any'] = "profile/get_profile/$1";

您没有使用正确的语法

更改

$route['profile/:any'] = "profile/get_profile/$1";

$route['profile/(:any)'] = "profile/get_profile/$1";