Php Codeigniter——添加“;主动”;css类,如何应用于链接?

Php Codeigniter——添加“;主动”;css类,如何应用于链接?,php,codeigniter,Php,Codeigniter,我有一个这样的url http://localhost/bestbookfinder.com/viewallbooks/books/pgn/grid/6 其中: bestbookfinder.com:项目名称 查看所有书籍:类名 书籍:功能 pgn:常量参数 栅格:视图类型 6:分页当前页码 因此,现在我尝试读取上面显示的url,并用下面的代码应用CSS类,但不幸的是,我的代码不起作用。 我想当我试图读取url时,我犯了一个错误 请帮我解决这个问题 <?php if ( $this->

我有一个这样的url
http://localhost/bestbookfinder.com/viewallbooks/books/pgn/grid/6

其中:

bestbookfinder.com:项目名称

查看所有书籍:类名

书籍:功能

pgn:常量参数

栅格:视图类型

6:分页当前页码

因此,现在我尝试读取上面显示的url,并用下面的代码应用CSS类,但不幸的是,我的代码不起作用。 我想当我试图读取url时,我犯了一个错误

请帮我解决这个问题

<?php
if ( $this->uri->uri_string() == '/books/pgn/grid' )//i think mistake is here
 {
  echo "".anchor(base_url().'viewallbooks/books/pgn/grid/'.$this->uri->segment(5),'  Grid', array('id' => 'gridactive'))."";
 }
?>

从-
uri\u string()返回一个包含完整uri的字符串。因此,在您的示例中,这将是
“viewallbooks/books/pgn/grid/6”

因此
“viewallbooks/books/pgn/grid/6”!='/图书/pgn/grid'

就这样做吧:

if ($this->uri->segment(4) == "grid")
{
   // do something
}
if($this->uri->segment(4) == 'grid'){
    //carry on