What is the purpose of the $_GET superglobal in PHP?

The $_GET superglobal in PHP is used to collect form data after submitting an HTML form with the method="get". It retrieves variables from the query string in the URL. This allows for passing data between pages easily and securely.

// Example of using the $_GET superglobal to retrieve form data
if(isset($_GET['username'])){
    $username = $_GET['username'];
    echo "Hello, $username!";
}