This question already has an answer here:
I have a file called file.php with this content:
<?php
$foo = 'hello';
?>
<div id="fileContent">
<?php echo($foo) ?>
...some content here
</div>
In other file called result.php, I call the file.php with the method file_get_contents():
<div id="resultContent">
<?php echo(file_get_contents('file.php')) ?>
</div>
But, I can´t print the internal variable $foo in my result.php file. Only appears as:
<!--?php echo($q); ?-->
Can I get this result? //print hello in the result.php file
</div>