带有php文件的PHP file_get_contents

I'm using file_get_contents() to merge a template and separate content and output them together as a page.

The problem I'm having is that if either of these files have a PHP statement,

<?php
    echo "example";
?>

The PHP isn't actually run, and the statement just seems to be part of the markup:

enter image description here

I thought at first that the PHP at the file I'm loading wouldn't be run first, but then I made a test page with the following:

<?php
    echo file_get_contents("http://stackoverflow.com");
?>

And uploaded it here to see that it works fine (processes the PHP first).

Should I be using a different function maybe?

You just need to include() the PHP file.

Be wary of the security concerns.

If you want to capture the file's output, use output buffering.