class IPAddress (View source)

Constants

FORMAT_HEX

FORMAT_IP_STRING

Properties

protected $ipHex

Methods

__construct(string|null $ipAddress = null, bool $isHex = false)

Builds the IPAddress object from the ip address string provided, or from a hexadecimal string If no ip address is provided, it can be set later by running the setIp function.

$this
setIp(string $ipAddress, bool $isHex = false)

Sets the current IP Address.

string|null
getIp(int $format = self::FORMAT_HEX)

Returns the IPAddress string, null if no ip address has been set.

bool
isIpSet()

No description

string
hex2bin(string $hex)

Fallback function for those using < PHP 5.4 Decodes a hexadecimally encoded binary string.

bool
isLoopBack()

Used to check of the current IP is a loopback IP address.

bool
isPrivate()

Returns true if the IP address belongs to a private network, false if it is not.

bool
isLinkLocal()

Returns true if the IP is a Link-local address, false if it is not.

isIPv4()

No description

isIPv6()

No description

Details

__construct(string|null $ipAddress = null, bool $isHex = false)

Builds the IPAddress object from the ip address string provided, or from a hexadecimal string If no ip address is provided, it can be set later by running the setIp function.

Parameters

string|null $ipAddress
bool $isHex

$this setIp(string $ipAddress, bool $isHex = false)

Sets the current IP Address.

Parameters

string $ipAddress
bool $isHex

Return Value

$this

string|null getIp(int $format = self::FORMAT_HEX)

Returns the IPAddress string, null if no ip address has been set.

Parameters

int $format

Uses the IPAddress::FORMAT_* constants

Return Value

string|null

Exceptions

Exception

Throws an exception if the value is not null and no valid format constant is given

protected bool isIpSet()

No description

Return Value

bool

Returns true if the IP address is set

string hex2bin(string $hex)

Fallback function for those using < PHP 5.4 Decodes a hexadecimally encoded binary string.

Parameters

string $hex

Return Value

string

Returns the binary representation of the given data

bool isLoopBack()

Used to check of the current IP is a loopback IP address.

Return Value

bool

returns true for loopback IP's, returns false if it is not a loopback IP

Exceptions

Exception

if no IP is set

bool isPrivate()

Returns true if the IP address belongs to a private network, false if it is not.

Return Value

bool

Exceptions

Exception

bool isLinkLocal()

Returns true if the IP is a Link-local address, false if it is not.

Return Value

bool

Exceptions

Exception

isIPv4()

No description

isIPv6()

No description