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

Php codeigniter URI路由问题:输出为$1而不是名称,php,codeigniter,Php,Codeigniter,我正在努力实现这样的目标: example.com/profile/abc 但是下面的代码给出了如下输出 $1,而不是配置文件名称。这里-例如-变量$name的输出应该是abc,但输出是$1 控制器 Routes.php 您使用的语法不正确 改变 到 class Profile extends CI_Controller { public function get_profile($name) { echo $name; } } $route['profile/:an

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

example.com/profile/abc

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

控制器

Routes.php


您使用的语法不正确

改变

class Profile extends CI_Controller
{
   public function get_profile($name)
   {
    echo $name;
   }
}
$route['profile/:any'] = "profile/get_profile/$1";
$route['profile/:any'] = "profile/get_profile/$1";
$route['profile/(:any)'] = "profile/get_profile/$1";