Codeigniter:在另一个函数内调用一个函数,并将其URL替换为名为

时间:2019-10-22 05:42:35

标签: php codeigniter

我有以下示例代码:

控制器

public function one()
{
   $this->two();  
   // url equals localhost/project/index.php?/one
}

public function two()
{
   // some code.. 
   // url still equals localhost/project/index.php?/one
}

每当我在one()下调用two()时,如何将URL更改为 localhost / project / index.php?/ two

1 个答案:

答案 0 :(得分:0)

希望此示例将帮助您理解路线概念:

控制器

class Abc extends CI_Model {
 public function one()
 {
 }

 public function two()
 {
 }
}

config => 路由

$ route ['new-first-url'] ='abc / one';

$ route ['new-second-url'] ='abc / two';

在浏览器网址中-

对于方法一=> https://localhost:80/project_name/new-first-url

对于方法2 => https://localhost:80/project_name/new-second-url