PHP code example of stormcode / php-domain-parser

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

    

stormcode / 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->getRegisterableDomain('www.scottwills.co.uk'));
var_dump($parser->getPublicSuffix('www.scottwills.co.uk'));
 json
{
    "ormcode/php-domain-parser": "~1.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->publicSuffix;

// $publicSuffix = 'com.au'