基于PHP的HTML验证器 [英] PHP Based HTML Validator

查看:95
本文介绍了基于PHP的HTML验证器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到一个基于PHP的HTML(如WC3-Like)Validator,它可以查找无效的HTML或XHTML。我搜索了一下Google,但很好奇,如果有人使用过他们特别喜欢的。



我有一个字符串中的HTML:

  $ html =< html>< head> .....< / body>< / html>; 

我希望能够测试页面,并让它返回错误。 (不回显/打印任何东西)



我见过:

- http://www.bermi.org/xhtml_validator

- http://twineproject.sourceforge.net/doc/phphtml.html



背景是,我想要在每个页面上运行一个函数/类,检查自上次访问日期(或类似情况)以来文件是否已被修改,如果没有,请运行验证程序,以便我在编码时立即通知无效的HTML。

解决方案

没有必要在这一个上重新发明轮子。已经有一个与W3C HTML验证器API接口的PEAR库。他们愿意为你做这项工作,为什么不让他们呢? :)

I need to find a PHP based HTML (as in WC3-Like) Validator that can look for invalid HTML or XHTML. I've searched Google a little, but was curious if anyone has used one they particularly liked.

I have the HTML in a string:

$html = "<html><head>.....</body></html>";

And I would like to be able to test the page, and have it return the errors. (Not echo/print anything)

I've seen:
-http://www.bermi.org/xhtml_validator
-http://twineproject.sourceforge.net/doc/phphtml.html

The background for this is that I'd like to have a function/class that I run on every page, check if the file has been modified since the last access date (or something similar to that), and if it hasn't, run the validator so I am immediately notified of invalid HTML while coding.

解决方案

There's no need to reinvent the wheel on this one. There's already a PEAR library that interfaces with the W3C HTML Validator API. They're willing to do the work for you, so why not let them? :)

这篇关于基于PHP的HTML验证器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆