Which function should i use for testin if a var isset or not?
- by streetparade
I'm sometimes confused to using which one of them,
say i have a function called getmember($id)
function getmember($id)
{
// now this is the confusing part
// how do i test if a $id was set or not set?
//solution 1
if(empty($id))
{
return false;
}
// solution 2
if(isset($id))
{
return false;
}
}
Thats sometimes not clear tome some times if a parameter in a function is set like function($var="")
Then i do
if($var ==="")
{
return false;
}
What should i use the next time isset ? emtyp ? or ===''