How can PHP code be executed within an HTML page to retrieve URL variables?

To execute PHP code within an HTML page to retrieve URL variables, you can use the `$_GET` superglobal array in PHP. This array contains key-value pairs of variables passed to the current script via the URL parameters. By accessing the values of these variables using `$_GET['variable_name']`, you can retrieve and use them in your PHP code.

<?php
// Retrieve the value of the 'id' URL variable
$id = $_GET['id'];

// Use the retrieved variable in your PHP code
echo "The ID passed in the URL is: " . $id;
?>