整洁函数 parseString(),repairString(),cleanRepair() 之间有什么区别
我刚刚开始使用 tidy,但我对它的函数 parseString()
、repairString()
、cleanRepair()
感到困惑。我已经浏览了 php.net 手册和其他网站,但可以获得它吗? php 手册说,parseString()
解析存储在字符串中的文档,repairString()
修复存储在字符串中的文档。但解析和修复有什么区别呢?两者都接受可选参数,并且可以给它们相同的参数,那么有什么区别呢?何时使用哪个功能以及何时同时使用两者?我在教程中看到过,它使用了这两个功能。有人可以帮忙吗?如果您知道的话,还可以指出任何有用的链接。谢谢
I have just begun using tidy but i am confused by its functions parseString()
, repairString()
, cleanRepair()
. i have gone through the php.net manual and other sites but can get it? the php manual says that parseString()
parses the document stored in a string and repairString()
repairs the document stored in a string. But what is the difference between parsing and repairing. the both accept optional parameters and they can be given the same parameters so what is the difference? when to use which function and when both? i have seen in a tutorial,it used both the functions. can somebody help? also point to any useful links if you know. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
parseString
接受一个字符串,并创建一个新的tidy
实例。cleanRepair
清理并修复该tidy
实例的内容。然后,您可以通过转换tidy
实例(例如通过echo
ing)来获取整理后的 HTML。repairString
基本上一次性完成了所有这些工作。这种操作组合是最常见的选项,因此这是一种快捷方法。请注意,它返回一个字符串,而parseString
返回新的tidy
实例,而cleanRepair
返回一个布尔值以显示操作是否成功。所以这些(大约)是等价的:
parseString
takes in a string, and creates a newtidy
instance.cleanRepair
cleans and repairs the contents of thattidy
instance. You can then get the tidied HTML by converting thetidy
instance, e.g. byecho
ing it.repairString
basically does all this in one go. This combination of actions is the most common option, so this is a shortcut method. Notice that it returns a string, whereasparseString
returns the newtidy
instance andcleanRepair
returns a boolean to show whether the operation was successful.So these are (approximately) equivalent: