When I use file_get_contents()
function on a local file, the result contains php code, though I need HTML only.
Content of the file being read:
<?php echo '<p>Hello</p>';?>
And the result of file_get_contents called from a different file located in the same folder:
<?php echo file_get_contents('test.php'); //returns the following: string(31) "Hello'; ?>"
If I read a file from an external server, it returns HTML - as I would expect. So the question is: how do I get HTML output from the local file? Thank you all.
You can use the files url (not filepath), so it is processed by the server eg:
echo file_get_contents('http://website.com/test.php');
However include/require would be better, eg:
include 'test.php';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With