Is using file_get_contents() a better alternative to include() when loading file content into a variable in PHP?

When loading file content into a variable in PHP, using file_get_contents() is generally considered a better alternative to include(). This is because file_get_contents() simply reads the file content into a string variable, while include() executes the file as PHP code, which can potentially lead to unexpected behavior or security vulnerabilities if the included file contains PHP code that is not intended to be executed. Therefore, for loading file content into a variable, file_get_contents() is a safer and more efficient choice.

// Using file_get_contents to load file content into a variable
$fileContent = file_get_contents('file.txt');