Net_IPv6::compress()

Net_IPv6::compress() – compress an IPv6 address

Synopsis

require_once 'Net/IPv6.php';

string Net_IPv6::compress ( string $ip , boolean $force = false )

Description

Compresses an IPv6 address. RFC 2373 allows you to compress zeros in an address to '::'. This function expects an valid IPv6 address and compresses successive zeros to '::'

FF01:0:0:0:0:0:0:101 -> FF01::101
      0:0:0:0:0:0:0:1      -> ::1

By default, the method does not touch an already compressed address and returns the address as is. This happens also in case of an address that is compressed but can be compressed further, for example an address like FF01::0:1 will be returned as is.

Since version 1.2.1, you can change this behavoir to enforce compression by setting $force to true.

Parameter

  • string $ip - the IP address to compress

  • boolean $force - if true, an already compressed IP address will be compressed again

Return value

string - the compressed IP is an IPv6 address

Note

This function can be called statically.

Validation of IPv6 addresses (Previous) Uncompresses an IPv6 address (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.