PHP 整洁 &结束标签查询
我只是好奇为什么这有效:
$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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信,如果您输入
,大多数程序都会接受“直到行尾”,但如果您输入
,则不会能够匹配它开始的位置并忽略它。
(但我不是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)
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