|
file_get_contentsReads entire file into a string Description
string file_get_contents
( string
$filename
[, bool $use_include_path = false
[, resource $context
[, int $offset = 0
[, int $maxlen
]]]] )
This function is similar to file, except that
file_get_contents returns the file in a
string, starting at the specified 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
Return Values
The function returns the read data or Warning
This function may
return Boolean Errors/Exceptions
An Examples
Example #1 Get and output the source of the homepage of a website
<?php Example #2 Searching within the include_path
<?php Example #3 Reading a section of a file
<?php The above example will output something similar to: string(14) "lle Bjori Ro" Example #4 Using stream contexts
<?php Changelog
Notes
Tip
A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide. Warning
When using SSL, Microsoft IIS will violate the protocol by closing the connection without sending a close_notify indicator. PHP will report this as "SSL: Fatal Protocol Error" when you reach the end of the data. To work around this, the value of error_reporting should be lowered to a level that does not include warnings. PHP can detect buggy IIS server software when you open the stream using the https:// wrapper and will suppress the warning. When using fsockopen to create an ssl:// socket, the developer is responsible for detecting and suppressing this warning. See Also
|