如何在 PHP 中在 HTML 中顯示 XML?
如果字串已預格式化,並且需要相同的純文字表示形式,那麼它可以包含在 HTML <pre/> 標記中,並且可以使用 HTML 實體來轉義尖括號。這已在下面顯示 −
<?PHP echo '<pre>', htmlentities($string), '</pre>'; ?>
將字串分配給字串型別,並在上面顯示 XML 在 HTML 中顯示 −
示例
<?php $string = " <example> <example> <example_value>EXAMPLE</example_value> </example> </example> "; echo '<pre>', htmlentities($string), '</pre>'; ?>
輸出
這將產生以下輸出 −
<example> <example> <example_value>EXAMPLE</example_value> </example> </example>
廣告