Class IP
Provides parsing and transformation support for IPv4 and IPv6 addresses.
- Core\Object implements Core\Chainable
- Core\Set implements Core\Accessor
- Core\IP implements Core\Equality, Serializable, Core\Storable
Package: Core
Since: 3.0
Requires: PHP 5.3, Filter
Version: 1.1
Located at IP.inc.php
Methods summary
public
|
|
public static
|
|
public static
|
#
remoteIP( )
Returns new IP instance for the final remote client IP address, if any.
If a proxy connection is detected, this method tries to resolve the
final remote client IP by parsing all appropriate HTTP headers.
Otherwise this method behaves equally to the |
public static
string
|
|
public static
|
#
unpack( $data )
Returns an IP instance restored from a natural binary 4-byte (IPv4) or 16-byte (IPv6) string. |
public
string
|
|
public
string
|
#
brief( )
Formats the IP address in shortest possible notation. Uses the abbreviated notation for IPv6 addresses if possible to fold the longest chain of zero bytes. |
public
string
|
|
public
string
|
|
public
boolean
|
|
public
string
|
#
pack( )
Returns the natural binary 4-byte (IPv4) or 16-byte (IPv6) representation of the current IP address. |
public
string
|
|
public
|
|
protected
string
|
#
address( )
Formats the IP address in standard notation. Includes each chunk but does not pad components. |
protected
string
|
|
protected
string
|
#
ipv4( )
Returns IPv4 version of current IP. If the current IP is an IPv6
address, the IP is checked for IPv4 compatibility, mapping, 6to4 or
translation mode and the extracted IPv4 is returned. Otherwise the
method returns |
protected
string
|
#
ipv6Compatible( )
IPv6-compatible address conversion. If the IP address of this instance is an IPv4 address, the resulting IPv6 address is the equivalent of the IPv4 address, padded by zeroes. This special address is used by dual-stack devices that both support IPv4 and IPv6. |
protected
string
|
#
ipv6Embedded( )
IPv6-compatible address conversion in embedded format. Equals the IPv6 address returned by ipv6compatible() but uses a special format for improved readability by using standard IPv4 notion for the last two segments if the represented address is actually an IPv4 address. |
protected
string
|
#
ipv6Mapped( )
IPv4-mapped IPv6-address conversion. Used by hybrid dual-stack systems. The IPv4 address is embedded in an IPv6 address with a prefix of 80 bits zeroes and 16 bits ones. |
protected
string
|
#
ipv6To4( )
Network base address for 6to4 transitional networks. The IP address
is prefixed by |
protected
string
|
#
ipv6Translated( )
IPv4-translated IPv6 address used by stateless IP/ICMP translation. An
IPv4 address is prefixed by |
Methods inherited from Core\Object
__autocreateFactory()
,
__call()
,
__processParameters()
,
attachMethod()
,
chain()
,
getValueForKey()
,
getValueForKeyPath()
,
getValueForUndefinedKey()
,
issetValueForKey()
,
setValueForKey()
,
setValueForKeyPath()
,
setValueForUndefinedKey()
,
uuid()
Constants summary
integer |
IPv4
Denotes an IPv4 network address. |
#
4
|
integer |
IPv6
Denotes an IPv6 network address. |
#
6
|
Constants inherited from Core\Object
AnyParameterType
,
AutochainParameterType
,
AutocreateParameterType
,
BooleanParameterType
,
CharParameterType
,
EnumParameterType
,
IntegerParameterType
,
RealParameterType
,
StringParameterType
,
UserParameterType
Properties summary
protected
array
|
$_v_chunks
IP address chunks. For an IPv4 address, each chunk represents a single 8 bit address part, for an IPv6 address, each chunk represents a 16 bit address part. |
|
protected
integer
|
$_v_type
IP type identifier. Either |
Magic properties
public read-only
string
|
$address
Standard formatted address. |
public read-only
string
|
$brief
Formatted address in short notion. |
public read-only
array
|
$chunks
IP address chunks. |
public read-only
string
|
$hex
Address in hexadecimal notion. |
public read-only
string
|
$hostname
Reverse hostname of IP address or |
public read-only
string
|
$ipv4
Formatted IPv4 address or |
public read-only
string
|
$ipv6Compatible
IPv6-compatible address string. |
public read-only
string
|
$ipv6Embedded
IPv6-compatible address string in embedded format. |
public read-only
string
|
$ipv6Mapped
IPv4-mapped IPv6-address string. |
public read-only
string
|
$ipv6To4
6to4-compatible IPv6 address string. |
public read-only
string
|
$ipv6Translated
IPv4-translated IPv6 address string. |
public read-only
integer
|
$type
IP type identifier. Either |