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:

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?
Test your Programming skills with w3resource's quiz.
PHP: Tips of the Day
Checks a flat list for duplicate values, returning true if duplicate values exists and false if values are all unique
Example:
<?php function tips_Duplicates($items) { return count($items) > count(array_unique($items)); } print(tips_Duplicates([1, 2, 3, 4, 5, 5])); ?>
Output:
1
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises