將PHP 輸出捕捉到變數(shù)中
在多種目的產(chǎn)生動(dòng)態(tài)XML 的場(chǎng)景中,包括使用者預(yù)覽和作為post變量,將生成的XML 捕獲到變量中可以簡(jiǎn)化該過(guò)程。此方法不需要產(chǎn)生 XML 兩次,一次用於預(yù)覽,一次用於表單值,而是允許產(chǎn)生一次。
考慮以下程式碼結(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