Parse domain name from URL is used in many cases within the web project. During this short tutorial, we’ll provide an easy code snippet to get domain name from URL in PHP. Using our example script, you’ll be ready to extract only the domain name from any type of URL.
All PHP code are group together in getdomain() function. The $url param should be passed to getdomain() function, from which you would like to get the name . Getdomain() function returns the name if found and FALSE if not found.