PHP Classes

PHP TLD Domain Name: Determine the Top Level Domain from a given URL

Recommend this page to a friend!
  Info   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 344 All time: 7,037 This week: 122Up
Version Licenses PHP version Categories
tld 0.1GNU General Publi...5.3Networking, PHP 5
Description 

Author

This class can determine the Top Level Domain from a given URL.

It can parse a given URL to extract the respective domain name.

The class can lookup a domain definition file retrieve from the Mozilla site to determine the actual part of the URL domain that is the top level domain.

It can also retrieve an updated version of the the top level domain definition file from the Mozilla file, so the TLD definition is determined more accurately.

Innovation Award
PHP Programming Innovation award nominee
May 2013
Number 7
The top level domain is the part of a domain name that defines the end of a domain.

In some cases it is easy to determine the top level domain because it is the name after the last point in the domain name. In many other cases it is no so easy because it is not after the last point and there is no rule to determine it.

This class can determine what is the top level domain of most known domain names using a Mozilla domain file.

Manuel Lemos
Picture of Artur Barseghyan
Name: Artur Barseghyan <contact>
Classes: 4 packages by
Country: The Netherlands The Netherlands
Age: 44
All time rank: 204156 in The Netherlands The Netherlands
Week rank: 91 Up2 in The Netherlands The Netherlands Up
Innovation award
Innovation award
Nominee: 2x

Details

AUTHOR Artur Barseghyan (artur.barseghyan@gmail.com) LICENSE MPL 1.1/GPL 2.0/LGPL 2.1 DESCRIPTION Extracts the top level domain (TLD) from a URL given. List of TLD names is taken from http://mxr.mozilla.org/mozilla/source/netwerk/dns/src/effective_tld_names.dat?raw=1 USAGE EXAMPLE To get the top level domain name from the URL given: require 'tld/utils.php'; echo Tld::getTld("http://www.google.co.uk") To update/sync the tld names with the most recent version run the following from your terminal: php -f tld/update.php To run tests: php -f tld/tests.php

  Files folder image Files  
File Role Description
Files folder imageres (1 file)
Plain text file exceptions.php Class Exceptions
Accessible without login Plain text file readme.txt Doc. Readme
Accessible without login Plain text file tests.php Example Test/example
Accessible without login Plain text file update.php Appl. Update script to be used from command line
Plain text file utils.php Class Main file

  Files folder image Files  /  res  
File Role Description
  Accessible without login Plain text file effective_tld_names.dat.txt Data Test/example

 Version Control Unique User Downloads Download Rankings  
 0%
Total:344
This week:0
All time:7,037
This week:122Up