(PHP 4 >= 4.3.0, PHP 5, PHP 7)
file_get_contents — Reads entire file into a string
use_include_path
= FALSE
[, resourceoffset
= 0 [, int maxlen</code> ]]]] ) </div> <p> This function is similar to <a href="http://php.net/manual/en/function.file.php" target="_top" rel="noopener noreferer nofollow"> file() </a> , except that file_get_contents() returns the file in a <a href="http://php.net/manual/en/language.types.string.php" target="_top" rel="noopener noreferer nofollow"> string </a>, starting at the specified <code>offset</code>up to<code>maxlen</code> bytes. On failure,file_get_contents() will return <code>FALSE</code>. </p> <p> file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance. </p> <blockquote> <p> Note: </p> <p> If you're opening a URI with special characters, such as spaces, you need to encode the URI with <a href="http://php.net/manual/en/function.urlencode.php" target="_top" rel="noopener noreferer nofollow"> urlencode() </a> . </p> </blockquote></div><div id="refsect1-function.file-get-contents-parameters"> <h3> Parameters <a href="http://php.net/manual/en/function.file-get-contents.php#refsect1-function.file-get-contents-parameters" target="_top" rel="noopener noreferer nofollow"> ¶ </a> </h3> <dl> <dt> <code>filename</code> </dt> <dd> <p> Name of the file to read. </p> </dd> <dt> <code>use_include_path</code> </dt> <dd> <blockquote> <p> Note: </p> <p> As of PHP 5 the <code>FILE_USE_INCLUDE_PATH</code>constant can be used to trigger <a href="http://php.net/manual/en/ini.core.php#ini.include-path" target="_top" rel="noopener noreferer nofollow"> include path </a> search. This is not possible if <a href="http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration.strict" target="_top" rel="noopener noreferer nofollow"> strict typing </a> is enabled, since <code>FILE_USE_INCLUDE_PATH</code> is an <a href="http://php.net/manual/en/language.types.integer.php" target="_top" rel="noopener noreferer nofollow"> int </a> . Use <code>TRUE</code> instead. </p> </blockquote> </dd> <dt> <code>context</code> </dt> <dd> <p> A valid context resource created with <a href="http://php.net/manual/en/function.stream-context-create.php" target="_top" rel="noopener noreferer nofollow"> stream_context_create() </a> . If you don't need to use a custom context, you can skip this parameter by <code>NULL</code>. </p> </dd> <dt> <code>offset</code> </dt> <dd> <p> The offset where the reading starts on the original stream. Negative offsets count from the end of the stream. </p> <p> Seeking (<code>offset</code>) is not supported with remote files. Attempting to seek on non-local files may work with small offsets, but this is unpredictable because it works on the buffered stream. </p> </dd> <dt> <code>maxlen</code> </dt> <dd> <p> Maximum length of data read. The default is to read until end of file is reached. Note that this parameter is applied to the stream processed by the filters. </p> </dd> </dl></div><div id="refsect1-function.file-get-contents-returnvalues"> <h3> Return Values <a href="http://php.net/manual/en/function.file-get-contents.php#refsect1-function.file-get-contents-returnvalues" target="_top" rel="noopener noreferer nofollow"> ¶ </a> </h3> <p> The function returns the read data or <code>FALSE</code> on failure. </p> <div> Warning <p> This function may return Boolean <code>FALSE</code>, but may also return a non-Boolean value which evaluates to <code>FALSE</code>. Please read the section on <a href="http://php.net/manual/en/language.types.boolean.php" target="_top" rel="noopener noreferer nofollow"> Booleans </a> for more information. Use <a href="http://php.net/manual/en/language.operators.comparison.php" target="_top" rel="noopener noreferer nofollow"> the === operator </a> for testing the return value of this function. </p> </div></div><div id="refsect1-function.file-get-contents-errors"> <h3> Errors/Exceptions <a href="http://php.net/manual/en/function.file-get-contents.php#refsect1-function.file-get-contents-errors" target="_top" rel="noopener noreferer nofollow"> ¶ </a> </h3> <p>An <code>E_WARNING</code> level error is generated if <code>filename</code> cannot be found, <code>maxlength</code>is less than zero, or if seeking to the specified <code>offset</code> in the stream fails. </p></div><h2 class="w3-center">Function Helper For file_get_contents() Alternative</h2><pre><br>function http_get_contents(url)
echo get_contents(“http://google.com”); //define target url
[PHP] Function Helper For file_get_contents()
PermaLink: https://www.webmanajemen.com/2018/02/php-function-helper-for-filegetcontents.html
Google Rich Snippets | Schema Markup Validator | Google Pagespeed Insight