2017 © Pedro Peláez
 

library ip_address

IP address handling library

image

gwk/ip_address

IP address handling library

  • Friday, February 26, 2016
  • by gwkunze
  • Repository
  • 3 Watchers
  • 8 Stars
  • 5,371 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 3 Versions
  • 13 % Grown

The README.md

Ip Address Build Status

This library allows you to handle IP addresses in various forms (currently IPv4 only) and test whether an IP matches certain constraints (equality, in a subnet or in a range)., (*1)

Example

``` php <?php, (*2)

use IPAddress\IPv4\Address; use IPAddress\IPv4\Subnet;, (*3)

$address = new Address("1.2.8.200"); // These statements yield the same address $address = new Address(0x010208c8); $address = new Address(array(1, 2, 8, 200)); $address = new Address(array("1", "2", "010", "0xc8"));, (*4)

$subnet = new Subnet("1.2.3.4", "255.255.0.0"); // These statements yield the same subnet $subnet = Subnet::fromCidr("1.2.3.4", 16); $subnet = Subnet::fromString("1.2.3.4 255.255.0.0"); $subnet = Subnet::fromString("1.2.3.4/16");, (*5)

if($address->isPrivate()) { echo "Your address is in one of the RFC1918 Private networks.\n"; }, (*6)

if($subnet->match($address)) { echo "I know your address is in the \"$subnet\" subnet.\n"; // OUTPUT: I know your address is in the "1.2.3.4 netmask 255.255.0.0" subnet. }, (*7)

```, (*8)

The library's test have been run on both 32-bit and 64-bit php and should work on both. Please note that the Address class' int() method (which returns the integer representation of an IP address) will return a negative number for ip addresses larger than 127.255.255.255 on 32-bit php due to the fact that php doesn't support unsigned integers., (*9)

TODO

  • More utility methods
  • IPv6 support

Disclaimer

I have limited knowledge of IP addresses so I could have made some mistakes regarding terminology or even behavior of the library in certain cases., (*10)

License

MIT, see LICENSE, (*11)

The Versions

26/02 2016

dev-master

9999999-dev

IP address handling library

  Sources   Download

MIT

The Development Requires

by Gijs Kunze

ip utility network

26/02 2016

0.2

0.2.0.0

IP address handling library

  Sources   Download

MIT

The Development Requires

by Gijs Kunze

ip utility network

17/04 2013

0.1

0.1.0.0

IP address handling library

  Sources   Download

MIT

The Development Requires

by Gijs Kunze

ip utility network