在CodeIgniter中使用输入类

时间:2012-11-29 04:17:25

标签: codeigniter

我检索如下的网址

http://localhost/codeigniter/?first=value_on_first_param&second=value_on_second_param

在该URL处,我有代码来检索URL上有一些GET参数的URL

if( $first = $this->input->get( 'first' )
    && $second = $this->input->get( 'second' )
){

    echo 'first param: '.$first;
    echo '<br />';
    echo 'second param: '.$second;

}

然后我尝试打印分配给某些变量的参数输出

first param: 1
second param: value_on_second_param

如上所述,我的第一个参数值为1而不是value_on_first_param。为什么?我在这里做错了吗?感谢。

1 个答案:

答案 0 :(得分:0)

因为作业:

你做

$first = 
       $this->input->get( 'first' ) && 
$second = $this->input->get( 'second' ) 

就像

$first = 
      ( $this->input->get( 'first' ) && 
        $second = $this->input->get( 'second' )
      ) 

因此$first将获得真正的价值。

你必须使用它:

if( ($first = $this->input->get( 'first' ))
    && ($second = $this->input->get( 'second' ) )
){

    echo 'first param: '.$first;
    echo '<br />';
    echo 'second param: '.$second;

}
相关问题