Added an example for opening a URI

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@163442 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Aidan Lister 2004-07-16 11:20:24 +00:00
parent d62a61a076
commit 0852df0fcc

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.15 $ -->
<!-- $Revision: 1.16 $ -->
<!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.130 -->
<refentry id="function.file-get-contents">
<refnamediv>
@ -24,6 +24,22 @@
contents of a file into a string. It will use memory mapping techniques if
supported by your OS to enhance performance.
</para>
<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
$url = "http://foobar.com/with funny chars";
list($protocol, $uri) = split("//", $url);
$html = file_get_contents($proto . "//" . urlencode($uri));
?>
]]>
</programlisting>
</example>
&note.bin-safe;
&tip.fopen-wrapper;
&note.context-support;