Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

[PHP] Parse/Extract Domain name from URL

PHP

Do you need to parse only domain from current URL? If yes, then you are at the right place to get the PHP Code. PHP has parse_url built in function to parse a URL parameters. This function will parse the URL into an array. You can easily get the domain name from whole URL of your page using parse_url function. parse_url will give you ability to parse type of request, domain name, path of URL and query string. Look at below code.

Look at below code.

This array contains below elements.

[scheme] => 'http'
[url] - 'www.programmingfacts.com'
[path] - '/page.php'
[query] - 'id=1'
 
Thank You!
Share:

1 Comment

  • Do you mean like a webpage of your own where you can advirtese your work?If so use spruz.com, it is very simple and self explanatory. Was this answer helpful?

Leave a Reply

Your email address will not be published.