An alternative to php tidy?

笑着哭i 提交于 2019-11-27 02:59:43

问题


I use php tidy to process html input in my database,

$fragment = tidy_repair_string($dom->saveHTML(), array('output-xhtml'=>1,'show-body-only'=>1));

I have this php_tidy turned on in my server but my live server doesn't support tidy,

Fatal error: Call to undefined function tidy_repair_string() in /customers/0/5/a/mysite.com/httpd.www/models/functions.php on line 587

Any alternative can I have to fix this problem?


回答1:


I found htmLawed to be very fast. I found it when looking for an alternative to HTMLPurifier, which was very slow.




回答2:


Or simply pass through the DOMDocument object:

$dirty = "<xml>some content</xml>"
$x = new DOMDocument;
$x->loadHTML($dirty);
$clean = $x->saveXML();



回答3:


If you are on a RedHat / CentOS / Fedora linux box and have root access to your server you can run...

yum install php-tidy

as root. Then restart apache and that should get you going.

There may be errors about missing dependencies that need to be added but usually the above command will be all you need.

Other distributions will have slightly different commands but something similar should be available.

On windows you need to install it manually. Instructions can be found here... http://devzone.zend.com/article/761#Heading3




回答4:


HTML Purifier can rewrite HTML to be standards-compliant like HTML Tidy. If you need to filter that input for XSS prevention, etc., it will do that as well.

It's all PHP, so you should be able to use it on any server.



来源:https://stackoverflow.com/questions/6891416/an-alternative-to-php-tidy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!