PHP code example of xoops / regdom

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

    

xoops / regdom example snippets


use Xoops\RegDom\RegisteredDomain;

$regdom = new RegisteredDomain();

echo $regdom->getRegisteredDomain('https://www.google.com/');
// Output: google.com

echo $regdom->getRegisteredDomain('theregister.co.uk');
// Output: theregister.co.uk

var_dump($regdom->getRegisteredDomain('co.uk'));
// Output: NULL (co.uk is a public suffix, not a registrable domain)

// IDN support (

use Xoops\RegDom\RegisteredDomain;

// Validates if a cookie domain is appropriate for a given host
RegisteredDomain::domainMatches('www.example.com', 'example.com');  // true
RegisteredDomain::domainMatches('example.com', 'com');              // false (public suffix)
RegisteredDomain::domainMatches('google.com', 'facebook.com');      // false (cross-domain)
RegisteredDomain::domainMatches('192.168.1.1', '192.168.1.1');      // false (IP addresses)

use Xoops\RegDom\PublicSuffixList;

$psl = new PublicSuffixList();

$psl->isPublicSuffix('com');        // true
$psl->isPublicSuffix('co.uk');      // true
$psl->isPublicSuffix('example.com'); // false

$psl->getPublicSuffix('www.example.co.uk'); // 'co.uk'

$psl->isException('www.ck'); // true (PSL exception rule)

$metadata = $psl->getMetadata();
// Returns: active_cache, last_updated, days_old, rule_counts, needs_update