What is the purpose of the file_get_contents() function in PHP?

The file_get_contents() function in PHP is used to read the contents of a file into a string. It is commonly used to fetch the contents of a URL or a local file for further processing in a PHP script.

// Example usage of file_get_contents() to fetch the contents of a URL
$url = 'https://www.example.com/data.txt';
$data = file_get_contents($url);

echo $data;