Hi, I have some code which sends output directly to the user. I'd like to change it to send the output to a string, instead. This includes stuff outside php tags, as well as contents of "print" commands. For example, something like this... <?php $_SOMEGLOBAL['OUTPUT_TARGET'] = $mystring; ?>Blah blah <?php print "blah"; // $mystring should now be "Blah blah blah" and no output has been sent yet PHP: Is something like this possible?
You mean you want to append 'blah blah blah' onto $mystring? Just do $mystring=$mystring."<br/>blah blah blah"; Now you can print $mystring whenever you want - including your 'blah blah blah'
Thanks... Thing is, I'm hoping to avoid going through this rather large amount of code and changing all the prints to appends. (Moral of the story: in general, any time you're generating virtual pages, store all the input in a string from stage 1, and don't output it 'til the end...)
ob_start(); print "<p>Hello</p>"; print "<p>I am a blue rhinosceros.</p>"; $all_the_stuff_i_printed = ob_get_clean(); PHP: