Saturday, 31 August 2013

Newbie issue. How to check if input is empty in php, although the input could contain digit 0?

Newbie issue. How to check if input is empty in php, although the input
could contain digit 0?

I'm new to PHP and usually I use these lines to check if the input is empty:
if(!isset($_SESSION['z']) || strlen(trim($_SESSION['z']) == 0))
{
echo "Unknown";
}
But if the user types digit 0, a script recognises input as empty. How to
change these lines to recognise 0 as a string?

No comments:

Post a Comment