How to pass parameters in index function in codeigniter

后端 未结 12 1875
傲寒
傲寒 2020-12-14 03:02

here\'s an example of url: http://www.example.com/search/search-keyword

I am trying to make this work, I removed the index.php using .htaccess, search is the contro

12条回答
  •  感情败类
    2020-12-14 03:49

    This easiest way is just to use uri segments:

    class Search extends CI_Controller{
      function index(){
        $param=$this->uri->segment(2);
        echo $param;
      }
    }
    

    Or like Madmartigan said, use routes, which is probably the better way of doing this.

提交回复
热议问题