Which function should i use for testin if a var isset or not?
Posted
by streetparade
on Stack Overflow
See other posts from Stack Overflow
or by streetparade
Published on 2010-03-19T15:05:18Z
Indexed on
2010/03/19
15:11 UTC
Read the original article
Hit count: 110
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 ===''
© Stack Overflow or respective owner