將 PHP 輸出捕獲到變量中
在出于多種目的生成動態(tài) XML 的場景中,包括用戶預(yù)覽和作為post 變量,將生成的 XML 捕獲到變量中可以簡化該過程。此方法不需要生成 XML 兩次,一次用于預(yù)覽,一次用于表單值,而是允許生成一次。
考慮以下代碼結(jié)構(gòu):
<code class="php">$lots of = "php"; <xml> <morexml> <?php while(){ ?> <somegeneratedxml> <?php } ?> <lastofthexml> <?php ?> <html> <pre class="brush:php;toolbar:false"> The XML for the user to preview