Hooking <? echo ?> output
Posted: Sat Feb 03, 2007 4:14 am
Hi,
I've created a class that generates the XHTML for a webpage. When you call its ->OutputHtml() member function, it echos XHTML to the browser using the PHP 'echo', as you might expect.
I'd like instead to write the contents of the XHTML echoed to a file. Is there any way I can 'grab' or 'hook' the echo(es) from the ->OutputHtml() function and pass them as lines into a file (e.g. grab and then write line-by-line using fwrite(...)).
That way, I could use the class both for browser and file output, instead of needing a different 'mode' for each or different code.
Many thanks
M
I've created a class that generates the XHTML for a webpage. When you call its ->OutputHtml() member function, it echos XHTML to the browser using the PHP 'echo', as you might expect.
I'd like instead to write the contents of the XHTML echoed to a file. Is there any way I can 'grab' or 'hook' the echo(es) from the ->OutputHtml() function and pass them as lines into a file (e.g. grab and then write line-by-line using fwrite(...)).
That way, I could use the class both for browser and file output, instead of needing a different 'mode' for each or different code.
Many thanks
M