$current_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo "Current URL is: ".$current_url;
$url = "http://example.com/page.php?param1=value1¶m2=value2"; echo "The generated URL is: ".$url;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; $urlGenerator = UrlGeneratorInterface::ABSOLUTE_URL; $url = $urlGenerator->generate('route_name', ['parameter' => 'value']); echo "The generated URL is: ".$url;In this example, we are using the Symfony Routing package library to generate a URL. The code will generate a URL based on the given route name and parameters and display it to the user.