How can PHP be used to manipulate URLs for a cleaner appearance?
When working with URLs in PHP, it is common to encounter long, messy URLs that may contain unnecessary parameters or query strings. To manipulate URLs for a cleaner appearance, we can use PHP to extract, modify, or remove parts of the URL as needed. This can help improve the readability and user-friendliness of the URLs on our website.
// Example: Removing query strings from a URL
$url = "https://www.example.com/page.php?id=123&name=john";
$clean_url = strtok($url, '?');
echo $clean_url; // Output: https://www.example.com/page.php