PHP:file_get_contents显示PHP代码

I have this code:

<?php
echo file_get_contents("file.php");
?>

And in my file.php file, I have the following code:

<?php
include_once("../includes/connect.php");
$query = $db->prepare("select * from messages");
$query -> execute();
?>

when I run the code.. I got the following output:

prepare("select * from messages"); $query -> execute(); ?>

I tested this on other files also. The mysqli queries in the page were showing were not being performed. I want it to do the opposite. What am I doing wrong?

Obviously, echo file_get_contents("file.php"); is what are you doing wrong.

any reason you aren't using the same include you already used in the other file?

This is a BASIC concept in php. What you are looking for is include() or require()