Getting confused with empty, isset, !empty, !isset

后端 未结 6 461
感情败类
感情败类 2021-01-21 19:10

I have the following which doesn\'t work properly as $_GET[\'category\'] can also equal 0.

if ( empty( $_GET[\'category\'] ) ){
    // do something
         


        
6条回答
  •  既然无缘
    2021-01-21 19:45

    Make sure the name attribute of the element that is doing get on the previous page is set, preferably to the same as its id. Then:

    $category='';
    if ( !isset( $_GET['category'] ) ){
        //1
    } else {
        $category=$_GET['category'];
        //3
      if($category==0){
        //2
       }
    }
    

提交回复
热议问题