1. Go to this page and download the library: Download rincler/domain 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/ */
use \Rincler\Domain\Domain;
$domain = new Domain('example.net.ru');
echo $domain->getTld(); // ru
Domain::setCustomTlds(static function () {
return ['net.ru', 'org.ru'];
});
echo $domain->getTld(); // net.ru
use \Rincler\Domain\Domain;
use \Rincler\Domain\TldRetrievalMode
$domain = new Domain('example.net.ru');
Domain::setCustomTlds(static function () {
return ['net.ru', 'org.ru'];
});
echo $domain->getTld(TldRetrievalMode::TRUE()); // ru
echo $domain->getTld(TldRetrievalMode::CUSTOM()); // net.ru
echo $domain->getTld(TldRetrievalMode::MIX()); // net.ru
$domain = new Domain('example.ru');
echo $domain->getTld(TldRetrievalMode::TRUE()); // ru
echo $domain->getTld(TldRetrievalMode::CUSTOM()); // <null>
echo $domain->getTld(TldRetrievalMode::MIX()); // ru
use \Rincler\Domain\Domain;
use \Rincler\Domain\TldRetrievalMode
$domain = new Domain('example.net.ru');
Domain::setDefaultTldRetrievalMode(TldRetrievalMode::TRUE());
Domain::setCustomTlds(static function () {
return ['net.ru', 'org.ru'];
});
echo $domain->getTld(); // ru
// You can still pass the mode as argument:
echo $domain->getTld(TldRetrievalMode::CUSTOM()); // net.ru
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.