What is the best practice for handling undefined variables in PHP, specifically when checking if a key exists in $_GET?

When checking if a key exists in the $_GET superglobal array, it's important to handle cases where the key may be undefined to prevent PHP notices or warnings. One way to do this is by using the isset() function to check if the key exists before accessing it. This ensures that your code runs smoothly without any errors.

// Check if the key 'example_key' exists in the $_GET superglobal array
if (isset($_GET['example_key'])) {
    // Key exists, do something with it
    $value = $_GET['example_key'];
    echo "Value of 'example_key': " . $value;
} else {
    // Key does not exist
    echo "Key 'example_key' is not set in the URL parameters";
}