Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > a34ed6838d4b29d38abd504392a4a797 > files > 1200

php-manual-es-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>ip2long</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Manual de PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Funciones de Red"
HREF="ref.network.html"><LINK
REL="PREVIOUS"
TITLE="getservbyport"
HREF="function.getservbyport.html"><LINK
REL="NEXT"
TITLE="long2ip"
HREF="function.long2ip.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Manual de PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.getservbyport.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.long2ip.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.ip2long"
></A
>ip2long</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN49490"
></A
><P
>    (PHP 4 )</P
>ip2long&nbsp;--&nbsp;
      Converts a string containing an (IPv4) Internet Protocol dotted address
      into a proper address.
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN49493"
></A
><H2
>Description</H2
>int <B
CLASS="methodname"
>ip2long</B
> ( string ip_address)<BR
></BR
><P
>&#13;     The function <B
CLASS="function"
>ip2long()</B
> generates an IPv4 Internet
     network address from its Internet standard format (dotted string)
     representation.
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN49503"
></A
><P
><B
>Ejemplo 1. <B
CLASS="function"
>ip2long()</B
> Example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?php
$ip = gethostbyname("www.example.com");
$out = "The following URLs are equivalent:&#60;br&#62;\n";
$out .= "http://www.example.com/, http://".$ip."/, and http://".sprintf("%u",ip2long($ip))."/&#60;br&#62;\n";
echo $out;
?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
     <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
       Because PHP's integer type is signed, and many IP addresses will
       result in negative integers, you need to use the "%u" formatter of
       <A
HREF="function.sprintf.html"
><B
CLASS="function"
>sprintf()</B
></A
> or <A
HREF="function.printf.html"
><B
CLASS="function"
>printf()</B
></A
> to get
       the string representation of the unsigned IP address.
      </P
></BLOCKQUOTE
></DIV
>
     This second example shows how to print a converted address with the
     <A
HREF="function.printf.html"
><B
CLASS="function"
>printf()</B
></A
> function :
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN49512"
></A
><P
><B
>Ejemplo 2. Displaying an IP address</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?php
$ip = gethostbyname("www.example.com");
printf("%u\n", ip2long($ip));
echo $out;
?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     See also: <A
HREF="function.long2ip.html"
><B
CLASS="function"
>long2ip()</B
></A
>
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.getservbyport.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Inicio</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.long2ip.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>getservbyport</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.network.html"
ACCESSKEY="U"
>Subir</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>long2ip</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>