Reputation: 1
I've already made a function which takes an input string representing a HTML document and validates it locally.
I'm trying to auto-validate my own PHP-generated webpages with it.
Can PHP store its own full output in a $string
so that it can send this to my validator function in the very end, after all output is done?
Upvotes: 0
Views: 17
Reputation: 73
Yup!
https://www.php.net/manual/en/function.ob-start.php
https://www.php.net/manual/en/function.ob-get-contents.php
Basically:
<?php
ob_start();
echo "Hello ";
$out1 = ob_get_contents();
echo "World";
$out2 = ob_get_contents();
ob_end_clean();
var_dump($out1, $out2);
?>
Upvotes: 1