How can PHP global variables like $_GET be effectively utilized to retrieve data from URLs?

To retrieve data from URLs using PHP global variables like $_GET, you can access the key-value pairs passed in the URL query string. This allows you to extract data such as form inputs or parameters passed in the URL. By accessing $_GET['key'], you can retrieve the corresponding value associated with the key in the URL.

// Example URL: http://example.com/index.php?id=123&name=John

$id = $_GET['id']; // Retrieves the value '123' from the URL parameter 'id'
$name = $_GET['name']; // Retrieves the value 'John' from the URL parameter 'name'

echo "ID: " . $id . "<br>"; // Output: ID: 123
echo "Name: " . $name; // Output: Name: John