What is the difference between URL and URI in PHP?

In PHP, a URL (Uniform Resource Locator) is a specific type of URI (Uniform Resource Identifier) that provides the location of a resource on the internet. While URLs specify the protocol (e.g., http, https), domain name, and path to a resource, URIs are a more general concept that can identify any resource, not just those accessible over the internet. To work with URLs in PHP, you can use the `parse_url()` function to break down a URL into its components, such as scheme, host, path, etc. This function helps in extracting specific parts of the URL for processing or manipulation.

$url = "https://www.example.com/path/to/resource";
$components = parse_url($url);

echo "Scheme: " . $components['scheme'] . "\n";
echo "Host: " . $components['host'] . "\n";
echo "Path: " . $components['path'] . "\n";