2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2004-08-28 06:26:38 +00:00
|
|
|
<!-- $Revision: 1.18 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.130 -->
|
|
|
|
<refentry id="function.file-get-contents">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>file_get_contents</refname>
|
|
|
|
<refpurpose>Reads entire file into a string</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>string</type><methodname>file_get_contents</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
2004-01-08 09:43:27 +00:00
|
|
|
<methodparam choice="opt"><type>bool</type><parameter>use_include_path</parameter></methodparam>
|
2003-04-08 00:07:12 +00:00
|
|
|
<methodparam choice="opt"><type>resource</type><parameter>context</parameter></methodparam>
|
2002-04-15 00:12:54 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
2003-01-06 23:42:51 +00:00
|
|
|
Identical to <function>file</function>, except that
|
2003-01-06 23:52:22 +00:00
|
|
|
<function>file_get_contents</function> returns the file in a string.
|
2004-01-16 19:29:09 +00:00
|
|
|
On failure, <function>file_get_contents</function> will return &false;.
|
2002-04-15 00:12:54 +00:00
|
|
|
</para>
|
2003-05-29 20:10:20 +00:00
|
|
|
<para>
|
|
|
|
<function>file_get_contents</function> is the preferred way to read the
|
|
|
|
contents of a file into a string. It will use memory mapping techniques if
|
2003-06-29 19:58:30 +00:00
|
|
|
supported by your OS to enhance performance.
|
2003-05-29 20:10:20 +00:00
|
|
|
</para>
|
2004-07-16 11:20:24 +00:00
|
|
|
<example>
|
|
|
|
<title>Using <function>file_get_contents</function> with a URI</title>
|
|
|
|
<para>
|
|
|
|
If you're opening a URI with special characters, such as spaces, you need to encode
|
|
|
|
the URI with <function>urlencode</function>.
|
|
|
|
</para>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
2004-08-28 06:26:38 +00:00
|
|
|
$url = 'http://example.com/with funny chars';
|
2004-08-28 06:22:46 +00:00
|
|
|
list($protocol, $uri) = split('//', $url);
|
|
|
|
$html = file_get_contents($protocol . '//' . urlencode($uri));
|
2004-07-16 11:20:24 +00:00
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
2002-04-15 00:12:54 +00:00
|
|
|
¬e.bin-safe;
|
|
|
|
&tip.fopen-wrapper;
|
2004-04-14 05:28:54 +00:00
|
|
|
¬e.context-support;
|
2004-02-19 16:06:56 +00:00
|
|
|
&warn.ssl-non-standard;
|
2002-04-23 22:10:15 +00:00
|
|
|
<simpara>
|
2004-05-18 14:23:19 +00:00
|
|
|
See also <function>fgets</function>, <function>file</function>,
|
2002-04-23 22:10:15 +00:00
|
|
|
<function>fread</function>, <function>include</function>,
|
|
|
|
and <function>readfile</function>.
|
|
|
|
</simpara>
|
2002-04-15 00:12:54 +00:00
|
|
|
</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:"../../../../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
|
|
|
|
-->
|