Search code examples
phpfiledebuggingechofwrite

How do I use fwrite() to write html content to current page as echo does?


I am debugging my web site, and I want to switch the target of fwrite() between the current html page and a file. I tried fopen("php://stdout", "w"), but not work.

Is there a way to enable this ? I don't want to change each line of fwrite to echo and change it back when I finish debugging. I am a novice to PHP and didn't find a proper solution after google.


Solution

  • php://output

    php://output is a write-only stream that allows you to write to the output buffer mechanism in the same way as print() and echo().

    http://php.net/manual/en/wrappers.php.php