PHP中的X / Html Validator [英] X/Html Validator in PHP
问题描述
但我不知道我是否可以将它安装在廉价的托管服务器上。我不这么认为。
我需要我的内容管理系统中的seo工具的验证器,因此它必须非常便于携带。
我喜欢使用W3C,但前提是它是可移植的。我也可以使用Curl,但它不会是优雅的解决方案。
到目前为止,我发现的最好的一个是: http://phosphorusandlime.blogspot.com/2007/09/php-html-validator-class.html a> 是否有任何验证工具与W3C相媲美,但可移植(只有PHP不依赖于定制包)? 如果您想验证(X)HTML文档,您可以使用PHP的本地 手册中的例子: First thing: I know that there is interface to W3C validator: http://pear.php.net/package/Services_W3C_HTMLValidator/
But I don't know if I can install it on cheap hosting server. I don't think so. I need validator for my seo tools within my Content Managment System so it must be pretty much portable. I would love to use W3C but only if it would be portable. I can also use Curl for this but it won't be elegant solution. The best one I found so far is: http://phosphorusandlime.blogspot.com/2007/09/php-html-validator-class.html Is there any validator comparable to W3C but portable (only PHP that does not depend on custom packages)? If you want to validate (X)HTML documents, you can use PHP's native Example from Manual: If you want the individual errors, fetch them with 这篇关于PHP中的X / Html Validator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
DOM
扩展名:
$ dom = new DOMDocument;
$ dom-> load('book.xml'); //见load,loadXml,loadHtml和loadHtmlFile的文档$ b $ if if($ dom-> validate()){
echoThis document is valid!\\\
;
$ / code $ / pre
如果你想要单个错误,请使用 libxml_get_errors()
DOM
extension:$dom = new DOMDocument;
$dom->load('book.xml'); // see docs for load, loadXml, loadHtml and loadHtmlFile
if ($dom->validate()) {
echo "This document is valid!\n";
}
libxml_get_errors()