Is it possible to add the output of print() to a variable?
I have the following situation:
I have a php file which looks something like this:
You can capture output with the ob_start() and ob_get_clean() functions:
ob_start();
print("abc");
$output = ob_get_clean();
// $output contains everything outputed between ob_start() and ob_get_clean()
Alternatively, note that you can also return values from an included file, like from functions:
a.php:
return "";
b.php:
$html = include "a.php"; // $html will contain ""