Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 17211 программистов и 1834 робота. Сейчас ищут 1624 программиста ...
Net_IPv4::calculate()
Вернуться к: Net_IPv4
Net_IPv4::calculate()
Net_IPv4::calculate() – Calculates network information based on an IP address and netmask.
Synopsis
require_once 'Net/IPv4.php';
mixed calculate ( )
Fully populates the object properties based on the IP address and netmask/bitmask properties. Once these two fields are populated, calculate() will perform calculations to determine the network and broadcast address of the network.
Example
Calculating broadcast and network address
<?php
require 'Net/IPv4.php';
// create IPv4 object
$ip_calc = new Net_IPv4();
// set variables
$ip_calc->ip = "192.168.1.10";
$ip_calc->netmask = "255.255.255.0";
/* alternative method with numerical values:
$ip_calc->long = 3232235786;
$ip_calc->bitmask = 24;
*/
// calculate
$error = $ip_calc->calculate();
if (!is_object($error))
{
// if returned true, output
echo "Your network address: ".$ip_calc->network."<br />";
echo "Your broadcast address: ".$ip_calc->broadcast."<br />";
}
else
{
// otherwise handle error
echo "An error occured: ".$error->getMessage();
}
?>
Return value
boolean - Returns TRUE on success, PEAR_Error on failure.
Note
This function can not be called statically.
Вернуться к: Net_IPv4