Syntax
string file_get_contents ( string $filename [, int $flags [, resource $context [, int $offset [, int $maxlen]]]] ); |
Definition and Usage
This function is identical to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes.
Paramters
Parameter | Description |
---|---|
filename | Name of the file to read. |
flags | The value of flags can be any combination of the following flags joined with the binary OR (|) operator.
|
context | A valid context resource created with stream_context_create(). If you don't need to use a custom context, you can skip this parameter by NULL. |
offset | The offset where the reading starts. |
maxlen | Maximum length of data read. |
Return Value
The function returns the read data or FALSE on failure.
Example
Following is the usage of this function:
<?php $lines = file_get_contents('http://www.example.com/'); # This will read complete index.htm file. echo $lines; ?> |
No comments:
Post a Comment