Storing the HTML output from a local PHP file into a string using file_get_contents
Posted
by bobo
on Stack Overflow
See other posts from Stack Overflow
or by bobo
Published on 2010-05-04T04:54:59Z
Indexed on
2010/05/04
4:58 UTC
Read the original article
Hit count: 280
php
|file-get-contents
There is a header.php file and it contains some php codes that return HTML. I know I can use require, include to echo the results, but what I want to do is to store its processed output string into a variable.
In a page, I used:
$headerHTML=file_get_contents('header.php');
Then I got the PHP code output rather than the processed HTML output. I know adding http:// would help. But I prefer to keep using relative path, how can I tell the function to treat the php file correctly?
© Stack Overflow or respective owner