Posts Tagged ‘parse’

Glossary: SLD and ccSLD (Second Level Domain, and country code SLDs)

A SLD or “Second Level Domain” is all often called the “domain” or “base domain.”

Most of the time when people buy a domain, they are buying a Second Level Domain. To get even more specific, they are buying a SLD + TLD combination.

When a ccSLD – or “country code Second Level Domain” – is used, then a user will actually be buying a third level domain.

ccSLDs can make it difficult for developers to deal with domains, in the sense that many developers have to parse out URLs for many reasons, but there is no hard set rule on how to parse a domain out. You just have to have a comprehensive list of all ccSLDs and their corresponding ccTLDs in order to properly distinguish the users “base domain” from their “domain extension.”

How do I parse out the subdomain from the TLD in PHP?

How do I use PHP’s parse_url() function to separate out the base domain from the domain extension?
How do I use PHPto extract the domain from a URL?
How do I extract the domain when it is using a ccSLD, or “country code second level domain”, such as .com.au and .co.uk?

PHP’s parse url function is quite handy, but not all powerful, and it cannot distinguish between domains and subdomains. (more…)