How do I capture PHP output into a variable?

后端 未结 4 1790
猫巷女王i
猫巷女王i 2020-11-27 04:04

I\'m generating a ton of XML that is to be passed to an API as a post variable when a user click on a form button. I also want to be able to show the user the XML before han

4条回答
  •  执念已碎
    2020-11-27 05:07

    Put this at your start:

    ob_start();

    And to get the buffer back:

    $value = ob_get_contents();
    ob_end_clean();

    See http://us2.php.net/manual/en/ref.outcontrol.php and the individual functions for more information.

提交回复
热议问题