previousValidate the syntax of the given netmask. (Previous) (Next) Calculates network information based on an IP address and netmask.next

View this page in Last updated: Sun, 07 Feb 2010
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

Net_IPv4::parseAddress()

Net_IPv4::parseAddress() – Parse a CIDR address (address/netmask combination).

Synopsis

require_once('Net/IPv4.php');

bool parseAddress ( string $address )

Description

Parses a Classless Inter-Domain Routing address (e.g. 192.168.1.0/24) and stores information in the object variables network, ip, netmask, broadcast, long and bitmask.

Example

How to get netmask and broadcast from CIDR address

<?php

require('Net/IPv4.php');

$cidr '192.168.0.50/16';
$net Net_IPv4::parseAddress($cidr);
echo 
$net->network;   // 192.168.0.0
echo $net->ip;        // 192.168.0.50
echo $net->broadcast// 192.168.255.255
echo $net->bitmask;   // 16
echo $net->long;      // 3232235520 (long/double version of 192.168.0.50)
echo $net->netmask;   // 255.255.0.0

?>

Return value

boolean - Returns TRUE on success, PEAR_Error on failure.

Note

This function can not be called statically.

previousValidate the syntax of the given netmask. (Previous) (Next) Calculates network information based on an IP address and netmask.next

Download Documentation Last updated: Sun, 07 Feb 2010
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.