PHP empty() function

Home > PHP Tutorial > PHP empty() function

Best PHP Live Project Based Winter Training in Noida for more details click here



PHP empty() function

PHP empty() function checks whether a variable holds some value or  not.

Eg

<?php
	
if(isset($_GET['sub']))
	
{
	
if(empty($_GET['n']))
		
{
		
echo "fill your name first";
		
}
		
else
		
{
		
echo "welcome ".$_GET['n'];
		
}
	
}
 
?>
	
<form>
		
Enter your name<input type="text" name="n"/>
		
<input type="submit" name="sub" value="show my name"/>
	
</form>

Output welcome Rexx Enter your name