请问php如何格式化html代码文件?
网友回复
安装php的扩展tidy,然后运行以下代码:
<?php ob_start(); ?> <html>a html document</html> <?php $html = ob_get_clean(); // Specify configuration $config ...
点击查看剩余70%
还可以使用DOMDocument来格式化,代码如下:
<?php $html = '<body><div><p>hello</p><div></body>'; $dom = new DOMDocument(...
点击查看剩余70%