PHP code example of voku / php-domain-parser

1. Go to this page and download the library: Download voku/php-domain-parser 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/ */

    

voku / php-domain-parser example snippets




$host = $parser->parseHost('a.b.c.cy');
var_dump($host);



var_dump($parser->getSubdomain('www.scottwills.co.uk'));
var_dump($parser->getRegistrableDomain('www.scottwills.co.uk'));
var_dump($parser->getPublicSuffix('www.scottwills.co.uk'));
 json
{
    "ku/php-domain-parser": "~8.0"
    }
}
 php


 php


er = new Pdp\PublicSuffixListManager();
$parser = new Pdp\Parser($pslManager->getList());
$host = 'http://user:[email protected]:8080/path/to/page.html?query=string#fragment';
$url = $parser->parseUrl($host);
var_dump($url);
 php


$host = 'waxaudio.com.au';
$url = $parser->parseUrl($host);
$publicSuffix = $url->host->getPublicSuffix();

// $publicSuffix = 'com.au'

var_dump($parser->isSuffixValid('www.example.faketld');
// false

var_dump($parser->isSuffixValid('www.example.com.au');
// true