Wednesday , 26 April 2017
Home » PHP » [PHP] Get/Parse Domain Name From Current URL
[PHP] Get/Parse Domain Name From Current URL

[PHP] Get/Parse Domain Name From Current URL

Hello Friends,

Are you looking to parse Domain Name from Current URL ? If yes than you don’t need to use explode function. There is other easy way to parse domain name, website url from current url of page. You can parse the domain name using explode function as well but this is the easy way to get domain name from url. Please have a look and let me know which is easy way to get domain name from URL. 🙂

<?php
$current_web_url = "http://www.phpfreelancedevelopers.com/product.php?id=1";
$currenturlarr = parse_url($current_web_url);
print_r($currenturlarr);
?>

If you look at the results, You can see below result.

[scheme] => 'http'
[url] - 'www.phpfreelancedevelopers.com'
[path] - '/product.php'
[query] - 'id=1'
      
Plugin by: PHP Freelancer

About Rakshit Patel

I am PHP Freelancer, Rakshit Patel working as PHP Programmer India. I have developed this site to share my knowledge, thoughts and experience during the development of projects. We are group of developers working together. If you want to hire us for any PHP related work, you can reach me via Email, Phone or Chat.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.