isset()

Returns boolean TRUE or FALSE if the target variable is set or not.

 

<?php
	$myVar = 1;

	if (isset($myVar))
	{
		echo "\$myVar is set <br>";    //note $ is being escaped by prefixed \
	} else {
		echo "\$myVar is not set<br>";
	}

	if (isset($nothing))
	{
		echo "\$nothing is set <br>";
	} else {
		echo "\$nothing is not set <br>";
	}
?>

Displays:

$myVar is set

$nothing is not set

 

Leave a Reply