qwddz / domain-extractor
0.0.3
2022-03-09 09:57 UTC
Requires
- php: ^7.3 || ^8.0
- ext-curl: *
- ext-json: *
- symfony/polyfill-intl-idn: ^1.10
Requires (Dev)
- phpmd/phpmd: @stable
- phpunit/phpunit: ^8.5
- squizlabs/php_codesniffer: *
README
通过Composer
$ composer require qwddz/domain-extractor
用法
$extract = new Extract(); # For domain 'gist.github.com' $result = $extract->parse('shop.github.com'); $result->getFullHost(); // will return (string) 'shop.github.com' $result->getRegistrableDomain(); // will return (string) 'github.com' $result->isValidDomain(); // will return (bool) true $result->isIp(); // will return (bool) false # For IP '127.0.0.1' $result = $extract->parse('192.168.0.1'); $result->getFullHost(); // will return (string) '192.168.0.1' $result->getRegistrableDomain(); // will return null $result->isValidDomain(); // will return (bool) false $result->isIp(); // will return (bool) true