PHP 整洁 &结束标签查询

发布于 2024-09-16 04:38:45 字数 540 浏览 5 评论 0原文

我只是好奇为什么这有效:

$config = array('wrap' => 0,'show-body-only' => TRUE,);

$str = '<p>Hello World!';

$tidy = tidy_parse_string($str, $config);
tidy_clean_repair($tidy);
echo (htmlentities($tidy)); //outputs <p>Hello World!</p> 

虽然这不起作用:

$config = array('wrap' => 0,'show-body-only' => TRUE,);

$str = 'Hello World!</p>';

$tidy = tidy_parse_string($str, $config);
tidy_clean_repair($tidy);
echo (htmlentities($tidy)); //outputs Hello World! 

I'm just curious as to why this works:

$config = array('wrap' => 0,'show-body-only' => TRUE,);

$str = '<p>Hello World!';

$tidy = tidy_parse_string($str, $config);
tidy_clean_repair($tidy);
echo (htmlentities($tidy)); //outputs <p>Hello World!</p> 

while this doesn't:

$config = array('wrap' => 0,'show-body-only' => TRUE,);

$str = 'Hello World!</p>';

$tidy = tidy_parse_string($str, $config);
tidy_clean_repair($tidy);
echo (htmlentities($tidy)); //outputs Hello World! 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

嘦怹 2024-09-23 04:38:45

我相信,如果您输入

,大多数程序都会接受“直到行尾”,但如果您输入

,则不会能够匹配它开始的位置并忽略它。

(但我不是100%确定)

I believe if you put <p> that most programs accept that as "until the end of the line" but if you put a </p> it is not able to match where it started and disregards it.

(But I am not 100% sure)

夏末 2024-09-23 04:38:45

tidy_clean_repair() 函数尝试为您修复代码。但当然这个函数并不完美,无法准确猜测你想在第二个例子中写什么。所以它可能只是把它撕下来

the tidy_clean_repair() function tries to fix the code for you. but of course the function is not perfect and could not guess precisely what you wanted to write in the second example. so it probably just ripped it off

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文