How can PHP be used to extract variables from rewritten URLs?

To extract variables from rewritten URLs in PHP, you can use the $_GET superglobal array to access the parameters passed in the URL. When rewriting URLs, you can use mod_rewrite in Apache to create SEO-friendly URLs that map to specific PHP files or endpoints. By using mod_rewrite to rewrite URLs and then accessing the variables using $_GET in PHP, you can extract and use the parameters passed in the rewritten URLs.

RewriteEngine On
RewriteRule ^user/([0-9]+)$ user.php?id=$1 [L]

// Access the id parameter in user.php using $_GET
$id = $_GET['id'];
echo "User ID: " . $id;