What is the purpose of using file_get_contents in PHP and how does it differ from other file reading functions?

The purpose of using file_get_contents in PHP is to read the contents of a file into a string. It differs from other file reading functions like fopen and fread because it simplifies the process by directly returning the file contents as a string without the need for opening and closing the file handle separately.

// Using file_get_contents to read the contents of a file into a string
$file_contents = file_get_contents('example.txt');

// Output the contents of the file
echo $file_contents;