PHP code example of acamposm / ipv4-address-converter

1. Go to this page and download the library: Download acamposm/ipv4-address-converter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

acamposm / ipv4-address-converter example snippets


use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->toLong()
  ->get();

var_dump($converter);

use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->toBinary()
  ->get();

var_dump($converter);

use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->toBinary()
  ->withDotNotation()
  ->get();

var_dump($converter);

use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->toHexadecimal()
  ->get();

var_dump($converter);

use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->toHexadecimal()
  ->withDotNotation()
  ->get();

var_dump($converter);

use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->withDotNotation()
  ->all();

var_dump($converter);