What is the difference between using include and readfile/file_get_contents in PHP?

The main difference between using include and readfile/file_get_contents in PHP is that include is used to include and execute the contents of a file in the current script, while readfile/file_get_contents is used to read the contents of a file and output it directly to the browser without executing any PHP code within the file. If you want to include and execute PHP code from another file, you should use include. If you just want to read and output the contents of a file, you should use readfile or file_get_contents.

// Using include to include and execute PHP code from another file
include 'file.php';

// Using readfile to read and output the contents of a file
readfile('file.txt');

// Using file_get_contents to read the contents of a file
echo file_get_contents('file.txt');