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@334651 c90b9560-bf6c-de11-be94-00142212c4b1
214 lines
5.8 KiB
XML
214 lines
5.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: e41aab5ecacf449e51179886c17f1d41735b0234 Maintainer: seros Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.file">
|
|
<refnamediv>
|
|
<refname>file</refname>
|
|
<refpurpose>Transfiere un fichero completo a un array</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>file</methodname>
|
|
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
|
|
<methodparam choice="opt"><type>resource</type><parameter>context</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Transfiere un fichero completo a un array.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Puede usar <function>file_get_contents</function> para devolver el contenido
|
|
de un fichero como una cadena.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>filename</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Ruta del fichero.
|
|
</para>
|
|
&tip.fopen-wrapper;
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El parámetro opcional <parameter>flags</parameter> puede ser una, o
|
|
más, de las siguientes constantes:
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>FILE_USE_INCLUDE_PATH</constant>
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Busca el fichero en <link
|
|
linkend="ini.include-path">include_path</link>.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>FILE_IGNORE_NEW_LINES</constant>
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
No se añade nueva línea al final de cada elemento del array
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>FILE_SKIP_EMPTY_LINES</constant>
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Salta las líneas vacías
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>context</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Un recurso de contexto válido creado con la
|
|
función <function>stream_context_create</function>.
|
|
</para>
|
|
<para>
|
|
¬e.context-support;
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Devuelve el fichero a un array. Cada elemento del array se corresponde con una
|
|
línea del fichero, con el carácter nueva línea aún adjunto. Si falla,
|
|
<function>file</function> devuelve &false;.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Cada línea del array resultante incuirá el final de línea, a menos que
|
|
se use <constant>FILE_IGNORE_NEW_LINES</constant>, por lo que aún necesita
|
|
utilizar <function>rtrim</function> si no quiere que el final de línea esté
|
|
presente.
|
|
</para>
|
|
</note>
|
|
¬e.line-endings;
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>4.3.0</entry>
|
|
<entry>
|
|
<function>file</function> ahora es segura al trabajar con datos binarios
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>file</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Escribe un fichero en un array. En este ejemplo iremos a través de HTTP para
|
|
// obtener el código fuente HTML de una URL.
|
|
$líneas = file('http://www.example.com/');
|
|
|
|
// Recorre nuestro array, muestra el código fuente HTML como tal y muestra tambíen los números de línea.
|
|
foreach ($líneas as $num_línea => $línea) {
|
|
echo "Línea #<b>{$num_línea}</b> : " . htmlspecialchars($línea) . "<br />\n";
|
|
}
|
|
|
|
// Otro ejemplo, vamos a escribir una página web en una cadena. Vea también file_get_contents().
|
|
$html = implode('', file('http://www.example.com/'));
|
|
|
|
// Usando el parámetro opcional banderas a partir de PHP 5
|
|
$recortes = file('fichero.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
&warn.ssl-non-standard;
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>readfile</function></member>
|
|
<member><function>fopen</function></member>
|
|
<member><function>fsockopen</function></member>
|
|
<member><function>popen</function></member>
|
|
<member><function>file_get_contents</function></member>
|
|
<member><function>include</function></member>
|
|
<member><function>stream_context_create</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
|
|
-->
|