I have a file B590.php which is having a lot of html code and some php code (eg logged in username, details of user).
I tried using $html = file_get_content("B590.php");
But then $html
will have the content of B90.php as plain text(with php code).
Is there any method where I can get the content of the file after it has been evaluated? There seems to be many related questions like this one and this one but none seems to have any definite answer.
To store evaluated result into some variable, try this:
You can use
include()
to execute the PHP file and output buffering to capture its output:If you use
include
orrequire
the file contents will behave as though the current executing file contained the code of thatB590.php
file, too. If what you want is the "result" (ie output) of that file, you could do this:Example:
B590.php
current.php
will output:
Whereas, if current.php looks like this:
The output will be:
This answer was originally posted on Stackoverflow