Php {%%}在html中是什么意思
我想它是用来引用php的,但我不确定。我在html文件中看到一些类似这样的内容:Php {%%}在html中是什么意思,php,html,Php,Html,我想它是用来引用php的,但我不确定。我在html文件中看到一些类似这样的内容: {% if ban.reason %} <p class="reason"> {{ ban.reason }} </p> {% endif %} {%if ban.reason%} {{ban.reason} {%endif%} 此语法由读取此文件并生成最终HTML的模板引擎使用。 其中一些可能是Django或Smarty,如@karthikr所评论的。
{% if ban.reason %}
<p class="reason">
{{ ban.reason }}
</p>
{% endif %}
{%if ban.reason%}
{{ban.reason}
{%endif%}
此语法由读取此文件并生成最终HTML的模板引擎使用。
其中一些可能是Django或Smarty,如@karthikr所评论的。这是一个模板引擎系统,其语法基于。另一个代码示例:
{% extends "layout.html" %}
{% block body %}
<ul>
{% for user in users %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}
</ul>
{% endblock %}
还有一个例子:
<ul id="navigation">
<?php if (navigation) { ?>
<?php foreach ($navigation as $item) { ?>
<li><a href="<?php echo $item->href; ?>"><?php echo $item->caption; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
在模板引擎中:
<ul id="navigation">
{% for item in navigation %}
<li><a href="{{ item.href }}">{{ item.caption }}</a></li>
{% endfor %}
</ul>
{导航%中的项目的%1}
{%endfor%}
可能是django模板,也可能是smarty模板。这个问题不值得投票表决。这是一个完美的问题,可以帮助初学者。介于{%%}之间的代码是一个php表达式,{{}之间的代码是一个输出。{{ban.reason}}可以是或其他东西。您最好弄清楚正在使用哪个模板引擎。请阅读细枝模板引擎。可能重复的
<ul id="navigation">
<?php if (navigation) { ?>
<?php foreach ($navigation as $item) { ?>
<li><a href="<?php echo $item->href; ?>"><?php echo $item->caption; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
<ul id="navigation">
{% for item in navigation %}
<li><a href="{{ item.href }}">{{ item.caption }}</a></li>
{% endfor %}
</ul>