Thursday, July 3, 2008

How to check if a php variable is empty or not using PHP

You wanna check if a given string or php variable is empty?
You can easily do it using the php empty() function


<?php

$my_var = ''; //empty() also return true for 0

if (empty($my_var))
{
echo 'Its empty';
}
else
{
echo 'not empty';
}
?>




Get custom programming done at GetAFreelancer.com!

No comments:

Post a Comment