PHP code example of katmore / tld-enum
1. Go to this page and download the library: Download katmore/tld-enum library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
katmore / tld-enum example snippets
print_r(\TldEnum\TldList::TLD_LIST); //an array with every IANA TLD
use TldEnum\TldList;
echo "There are " . count(TldList::TLD_LIST) . " IANA TLDs\n";
$tldCheck = "com";
echo "Is '$tldCheck' a real TLD?\n";
if (in_array(strtolower($tldCheck), TldList::TLD_LIST)) {
echo " yes\n";
} else {
echo " no\n";
}
$tldCheck = "somethingWeird";
echo "Is '$tldCheck' a real TLD?\n";
if (in_array(strtolower($tldCheck), TldList::TLD_LIST)) {
echo " yes\n";
} else {
echo " no\n";
}