PHP - Fonction ip2long

Syntaxe

int ip2long ( string $ip_address )

Définition et utilisation

Il convertissait l'adresse ipv4 en entier long.

Valeurs de retour

Il renvoie un entier long ou affiche un message car l'adresse IP n'est pas valide.

Paramètres

Sr.Non Paramètres et description
1

ip_address

il contient une adresse IP.

Exemple

Essayez l'exemple suivant

<?php
   $ip = gethostbyname('www.tutorialspoint.com');
   $out = "The following URLs are equivalent:
   \n";
   
   $out .= 'http://www.tutorialspoint.com/, http://' . $ip . '/, 
      and http://' . sprintf("%u", ip2long($ip)) . "/
   \n";
   
   echo $out;
?>

Cela produira le résultat suivant -

The following URLs are equivalent:
http://www.tutorialspoint.com/, http://72.21.91.8/, and http://1209359112/