[英]Closing element tags in php
I have just started to learn PHP from books and have come across something I don't understand. 我刚刚开始从书籍中学习PHP,并且遇到了一些我不了解的东西。 In the book they never close html tags is this correct practice or should they be closed?
在这本书中,他们从不关闭html标签,这是正确的做法还是应该将其关闭? Here is an example of the books content:
这是书籍内容的示例:
<?php
$cars = array('Dodge'=>'Viper','Chevrolet'=>'Camaro','Ford'=>'Mustang');
echo '<dl><dt>Original Element Order:<dd>';
foreach($cars as $key => $value){
echo '•', $key.' '.$value;
}
?>
Could anyone tell me if this is correct and common practice? 谁能告诉我这是正确的常规做法吗? Thanks
谢谢
Some old books :). 一些旧书:)。 They definitely need to be closed.
他们肯定需要关闭。 You need to echo
</dd></dt></dl>
after the foreach loop. 您需要在foreach循环后回显
</dd></dt></dl>
。
The end tags for the <dt>
and <dd>
elements are optional in HTML. <dt>
和<dd>
元素的结束标记在HTML中是可选的。 The missing </dl>
is a problem though. 缺少的
</dl>
是一个问题。
Other issues with this fragment: 此片段的其他问题:
•
•
for a list instead of list markup <ul>
(but is simulated with •
) for key/value pairs <ul>
(但用•
进行模拟) dl
with only one dt
in it. dt
的dl
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.