PHP - file_get_contents
Trieda
Metóda - file_get_contents
(PHP 4 >= 4.3.0, PHP 5, PHP 7)
file_get_contents() reads a file and returns its contents as
string. The filename can be either a local path (absolute or relative), or a URL
(if the fopen-wrappers module is allowed).
Procedurálne
- function file_get_contents (string $filename, resource $context, int $offset = 0, int $maxlen) : string
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $filename | string | The path to the file or URL. On Windows, make sure that all backslashes are escaped properly. | |
| $context | resource | A context created by | |
| $offset | int | 0 | The offset where the reading starts. Not supported on remote files. If the offset is a negative number, it's treated from the end of the stream and goes backwards. |
| $maxlen | int | The maximum length of the input to be read. The whole file is read by default. |
Mávratovej hodnoty
Vracia: string
The file contents if the file can be read, false otherwise
Príklady
<?php
// Downloads the content of the URL 'https://www.ict.social/test.txt' and stores it in the $content variable, which is then printed.
$content = file_get_contents('https://www.ict.social/test.txt');
echo $content;
?>
