What are the advantages and disadvantages of using file_get_contents over include when displaying user-submitted content in PHP?

When displaying user-submitted content in PHP, it is important to consider security risks. Using file_get_contents to read the content from a file and display it can be safer than using include, as it does not execute PHP code. However, file_get_contents may still pose a risk if the content is not properly sanitized. It is recommended to use functions like htmlspecialchars to escape any potentially harmful content before displaying it to the user.

$user_content = file_get_contents('user_input.txt');
echo htmlspecialchars($user_content);