Does empty() function validate all of this cases:
1.var=null
2.var=empty string “”/” ”
3.var=not set
Example for validate use (Should I add some more code for validation or empty() enough?):
if(!empty($userName)){
//some code
}
else{
echo "not valid user name"
}
Edit: should isset() used before empty() or empty() includes the isset() case?
Given the following i would say it fits your needs:
EDIT:
This depends on the usage. IF you are in a position where you cant be sure
$usernameexists then you need to use isset first to avoid an error about a nonexistent variable. If on the other hand you are sure$usernamewill always exist then you can jsut test for the empty value and leave it at that.