tags:

views:

62

answers:

5
array(4) { ["id"]=>  int(0) ["pass"]=>  string(0) "" ["log_in"]=>  string(3) "no"  } 

now the problem in id when using isset it return true because its 0 when using empty i think its doing the same please help me is determine the best function to know its set or not

+4  A: 

empty return false for these:

"" (an empty string)
0 (0 as an integer)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
var $var; (a variable declared, but without a value in a class)

You need to use isset instead to check if it is there.

See:

empty vs isset

for more info. Thanks :)

Sarfraz
+1  A: 

Take a look at this chart: http://php.net/manual/en/types.comparisons.php

Regards

aefxx
+1  A: 

a simple if condition will do for you

if(id)
{
}

try it if it works.

Gaurav Sharma
its $_SESSION["id"] if it will work?
moustafa
Gaurav Sharma
+2  A: 
if($array['id'] === 0) {
  true
} ?
Steve
+1  A: 

if id is a database id is positive integer

so if($id>0) is one simple solution

OR

preg_match('#^[0-9]*$#', $id)

another

ntan