w3resource
php Programming Exercies

PHP Exercises : Get the full URL

PHP : Exercise-22 with Solution

Write a PHP script to get the full URL.

Sample Solution:

PHP Code:

<?php
$full_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
  echo $full_url."\n";
?>

Sample Output:

View the output in the browser

Flowchart:

Flowchart: Get the full URL

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a PHP function to test whether a number is greater than 30, 20 or 10 using ternary operator.
Next: Write a PHP script to compare the PHP version.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming