PHP – isset() Function to Verify if a Variable Has a Value

The isset() function in PHP checks to see if the value of a variable has been set. this can be useful in applications that allow users to login, or make sure that variables are actually set when large amounts of data have to be pulled into your application.

isset()

isset.php

<?php

$name = $_POST['name'];

if (isset($name)) {
    echo "<h1>Hello ".$name."</h1>";
} else {
    echo "<form action='isset.php' method='post'>";
    echo "Your Name? <input type='text' name='name'>";
    echo "<input type='submit'>";

}

?>

Be the first to comment

Leave a Reply