class DomainUtility (View source)

Domain name helpers: reverse-zone names, domain levels and second-level extraction.

Methods

static string
convertIPv4AddrToPtrRec(string $ip)

Convert IPv4 Address to PTR Record

static string
convertIPv6AddrToPtrRec(string $ip)

Convert IPv6 Address to PTR Record

static string|null
convertPtrRecToIpAddr(string $name)

Convert a full PTR record name back to the address it names

static array
resolveAddressAsRecordName(string $name, string $zoneName)

Read an IP address typed as a record name in a reverse zone as the PTR name it stands for

static int
getDomainLevel(string $name)

Return domain level for given name

static string
getSecondLevelDomain(string $name)

Return domain second level domain for given name

Details

static string convertIPv4AddrToPtrRec(string $ip)

Convert IPv4 Address to PTR Record

Parameters

string $ip

IPv4 Address

Return Value

string

PTR form of address

static string convertIPv6AddrToPtrRec(string $ip)

Convert IPv6 Address to PTR Record

Parameters

string $ip

IPv6 Address

Return Value

string

PTR form of address

static string|null convertPtrRecToIpAddr(string $name)

Convert a full PTR record name back to the address it names

Parameters

string $name

PTR record name, e.g. 1.2.0.192.in-addr.arpa

Return Value

string|null

The IPv4 or compressed IPv6 address, or null for a partial, classless or forward name

static array resolveAddressAsRecordName(string $name, string $zoneName)

Read an IP address typed as a record name in a reverse zone as the PTR name it stands for

A name that is not an address, or a zone that is not a reverse zone, is returned unchanged.

Parameters

string $name

The submitted record name

string $zoneName

The zone the record is added to

Return Value

array

The name to store, or why the address is refused

static int getDomainLevel(string $name)

Return domain level for given name

Parameters

string $name

Zone name

Return Value

int

domain level

static string getSecondLevelDomain(string $name)

Return domain second level domain for given name

Parameters

string $name

Zone name

Return Value

string

2nd level domain name