file_get_contents : Reads entire file into a string
This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.
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.
Parameters :
1 > filename : Name of the file to read.
2> use_include_path : Optional. Set this parameter to '1' if you want to search for the file in the include_path (in php.ini) as well
3> context : Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream. Can be skipped by using NULL.
4> offset :
The offset where the reading starts on the original stream.
Seeking (offset) 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.
5> maxlen :
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.
Example :
<?php
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>
This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.
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.
Parameters :
1 > filename : Name of the file to read.
2> use_include_path : Optional. Set this parameter to '1' if you want to search for the file in the include_path (in php.ini) as well
3> context : Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream. Can be skipped by using NULL.
4> offset :
The offset where the reading starts on the original stream.
Seeking (offset) 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.
5> maxlen :
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.
Example :
<?php
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>
Comments
Post a Comment