PHP code example of ossinkine / pseudo-ipv4
1. Go to this page and download the library: Download ossinkine/pseudo-ipv4 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/ */
ossinkine / pseudo-ipv4 example snippets
use Ossinkine\PseudoIpv4\PseudoIpv4Converter;
$ipv6 = '2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d';
$converter = new PseudoIpv4Converter();
$ipv4 = $converter->convert($ipv6);
use Ossinkine\PseudoIpv4\Exception\WrongIpv6Exception;
use Ossinkine\PseudoIpv4\PseudoIpv4Converter;
$ip = $_SERVER['REMOTE_ADDR'];
$converter = new PseudoIpv4Converter();
try {
$ipv4 = $converter->convert($ip);
} catch (WrongIpv6Exception $exception) {
$ipv4 = $ip;
}