$file = '/path/to/file.txt'; $content = file_get_contents($file); echo $content; // outputs the contents of the file
$file = 'http://example.com/file.txt'; $content = file_get_contents($file); echo $content; // outputs the contents of the file
$file = '/path/to/file.txt'; $content = file_get_contents($file, false, null, 10, 20); echo $content; // outputs 20 characters starting from the 10th characterThis example reads 20 characters from the 10th character of the file and outputs it. The `file_get_contents` function is part of PHP's core, so it does not require any additional package library to be installed.