Home > Article > Backend Development > How to use PHP function file_get_contents?
How to use the PHP function file_get_contents?
The function of file_get_contents function in PHP is to read the entire file into a string. Its syntax is "file_get_contents($filename)". The return value is the read character. The usage method is just Just pass the file path into $filename.
Usage examples
<?php $homepage = file_get_contents('http://www.example.com/'); echo $homepage; ?>
<?php // <= PHP 5 $file = file_get_contents('./people.txt', true); // > PHP 5 $file = file_get_contents('./people.txt', FILE_USE_INCLUDE_PATH); ?>
<?php // Read 14 characters starting from the 21st character $section = file_get_contents('./people.txt', NULL, NULL, 20, 14); var_dump($section); ?> string(14) "lle Bjori Ro"
Recommended tutorial: "PHP"
The above is the detailed content of How to use PHP function file_get_contents?. For more information, please follow other related articles on the PHP Chinese website!