3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php error_reporting(E_ALL); function ip6ptrtoip6($arpa) { $mainptr = substr($arpa, 0, strlen($arpa)-9); $pieces = array_reverse(explode(".",$mainptr)); $count=count($pieces); $hex = implode("",$pieces); $hex=str_pad($hex,32,'0'); $ipbin = pack('H*', $hex); $ipv6addr = inet_ntop($ipbin); if($count<32) { $ipv6addr .= '0/' . $count*4; } // dump_nice essentially captures the output of var_dump into a string so I can // at the bottom of the page. var_dump(array($arpa,$hex,error_get_last(),$ipv6addr)); return $ipv6addr; } ip6ptrtoip6("0.7.1.2.2.0.a.2.ip6.arpa");
Output for 5.2.0 - 7.1.7
array(4) { [0]=> string(24) "0.7.1.2.2.0.a.2.ip6.arpa" [1]=> string(32) "2a022170000000000000000000000000" [2]=> NULL [3]=> string(15) "2a02:2170::0/32" }
Output for 5.1.0 - 5.1.6
<br /> <b>Fatal error</b>: Call to undefined function error_get_last() in <b>/in/hteZr</b> on line <b>18</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.5
<br /> <b>Fatal error</b>: Call to undefined function inet_ntop() in <b>/in/hteZr</b> on line <b>12</b><br />
Process exited with code 255.
Output for 4.4.5 - 4.4.9
<br /> <b>Fatal error</b>: Call to undefined function: inet_ntop() in <b>/in/hteZr</b> on line <b>12</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.4.4
<br /> <b>Fatal error</b>: Call to undefined function: inet_ntop() in <b>/in/hteZr</b> on line <b>12</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Call to undefined function: inet_ntop() in <b>/in/hteZr</b> on line <b>12</b><br />