1. filename is the name of file or url. 2. include_path if enabled, Search for the file in the include_path as well 3. context this is set of options to modify the behavior of a stream 4. offset this value specifies starting position of file to read. 5. maxlen this value specifies number of bytes to read.
Syntax
PHP file_get_contents() function uses following syntax.string file_get_contents(string $filename, bool $include_path = false, resource $context, int $offset = 0, int $maxlen)
Read File Content to String
This php example script will read content from file and store into string variable.<?php $content = file_get_contents("input.txt"); echo $content; ?>
Read Content from URL to String
This php example script will read content from url and store into string variable.<?php $content = file_get_contents("http://example.com"); echo $content; ?>
Comments
Post a Comment