How can the "Undefined index" notice be prevented when working with $_GET variables in PHP?

When working with $_GET variables in PHP, the "Undefined index" notice can be prevented by checking if the index exists before trying to access it. This can be done using the isset() function to verify if the index is set in the $_GET array before using it.

if(isset($_GET['variable_name'])) {
    $variable = $_GET['variable_name'];
    // Use the variable here
} else {
    // Handle the case where the variable is not set
}