Write a PHP script, which will return the following component of the URL - PHP | IProgramX

Slip no. 3. Write a PHP script, which will return the following component of the URL
‘http:// www.example.com/php-example/index.php’
List of component: Scheme, Host, Path
Excepted o/p
Scheme: http
Host: www.example.com
Path:/php-example/index.php


PHP file :
<?php
                $url = 'http://www.example.com/php-example/index.php';
                print_r(parse_url($url));
                $scheme = parse_url($url,PHP_URL_SCHEME);
                echo "<br><br>Scheme : $scheme";
             
                $host = parse_url($url,PHP_URL_HOST);
                echo "<br><br>Host : $host";
                $path = parse_url($url,PHP_URL_PATH);
                echo "<br><br>path : $path";         
?>

Post a Comment

0 Comments