开发者

Why does count() return 0 here?

开发者 https://www.devze.com 2023-02-01 08:10 出处:网络
I have the following code : 开发者_如何学Pythonecho $gibs=Db::getResult($sql,$query); print_r($gibs);

I have the following code :

开发者_如何学Pythonecho $gibs=Db::getResult($sql,$query);
  print_r($gibs);
  count($gibs);
  if($gibid!='' && count($gibs)<=0){
   $gibs=array(
    'gibid'=>$gibid,
    'userid'=>$userid,
    'isowner'=>false
   );

  }

Resulting output :

ArrayArray ( ) 

why count($gibs) not returning any thing.

thats why the flow don't going in if condition.


To see the output of count($gibs); you should assign the function to some variable, or print it:

print_r(count($gibs));

In your case, it's value will be 0, because $gibs array is empty (it is seen out of the print_r output).

If condition might not work, because $gibid == 0

0

精彩评论

暂无评论...
验证码 换一张
取 消