What is the function of file_get_contents in PHP and what are common use cases for it?
The file_get_contents function in PHP is used to read the contents of a file into a string. This function can be used to retrieve data from a file, such as text files, JSON files, or even remote files via URLs. Common use cases for file_get_contents include reading configuration files, fetching data from APIs, and processing data stored in files.
// Example: Reading the contents of a text file
$file_contents = file_get_contents('example.txt');
echo $file_contents;