mirror of
https://github.com/php/doc-es.git
synced 2026-03-25 16:02:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@334672 c90b9560-bf6c-de11-be94-00142212c4b1
176 lines
4.7 KiB
XML
176 lines
4.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: e41aab5ecacf449e51179886c17f1d41735b0234 Maintainer: chuso Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
<refentry xml:id="function.ip2long" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>ip2long</refname>
|
|
<refpurpose>Convierte una cadena que contiene una dirección con puntos del Protocolo de Internet (IPv4) en una dirección apropiada</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>ip2long</methodname>
|
|
<methodparam><type>string</type><parameter>ip_address</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
La función <function>ip2long</function> genera una dirección de red
|
|
Internet IPv4 desde su representación en formato estándar de Internet
|
|
(cadena con puntos).
|
|
</para>
|
|
<para>
|
|
<function>ip2long</function> trabajará también con direcciones IP
|
|
no-completas. Lea <link xlink:href="&url.ip2long.tech;">&url.ip2long.tech;</link>
|
|
para más información.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>ip_address</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Una dirección en formato estándar.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Devuelve la dirección IPv4 o &false; si
|
|
<parameter>direccion_ip</parameter> es un valor inválido.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.2.10</entry>
|
|
<entry>
|
|
Antes de esta versión, <function>ip2long</function> según como devolverá un
|
|
número válido incluso si el valor no es una dirección con puntos (IPv4)
|
|
Internet Protocol.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>ip2long</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$ip = gethostbyname('www.example.com');
|
|
$salida = "Las siguientes URLs son equivalentes:<br />\n";
|
|
$salida .= 'http://www.example.com/, http://' . $ip . '/, y http://' . sprintf("%u", ip2long($ip)) . "/<br />\n";
|
|
echo $salida;
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Desplegar una dirección IP</title>
|
|
<para>
|
|
Este segundo ejemplo muestra cómo imprimir una dirección convertida con
|
|
la función <function>printf</function> tanto en PHP 4 como en PHP 5:
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$ip = gethostbyname('www.example.com');
|
|
$long = ip2long($ip);
|
|
|
|
if ($long == -1 || $long === FALSE) {
|
|
echo 'IP inválida, por favor intente de nuevo';
|
|
} else {
|
|
echo $ip . "\n"; // 192.0.34.166
|
|
echo $long . "\n"; // -1073732954
|
|
printf("%u\n", ip2long($ip)); // 3221234342
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
Ya que los tipos <type>integer</type> en PHP tiene signo, y muchas direcciones IP
|
|
resultarán en enteros negativos en arquitecturas de 32 bits, necesita usar el especificador de
|
|
formato "%u" de <function>sprintf</function> o
|
|
<function>printf</function> para obtener la representación en forma de cadena de
|
|
la dirección IP sin signo.
|
|
</para>
|
|
</note>
|
|
<note>
|
|
<para>
|
|
<function>ip2long</function> devolverá &false; para la IP
|
|
<literal>255.255.255.255</literal> en PHP 5 <= 5.0.2. Fue corregido
|
|
en PHP 5.0.3 cuando devolvía <literal>-1</literal> (al igual que en PHP
|
|
4).
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>long2ip</function></member>
|
|
<member><function>sprintf</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|