我有一些人的代码,他们使用twig而不是php来创建警报引导程序,我会将其更改为php编码,这就是twig编码:
{% for alert in [ 'info', 'success', 'warning', 'error'] %}
{% if app.session.hasFlash(alert) %}
<div class="alert alert-{{ alert }}">
<button class="close" data-dismiss="alert">×</button>
{{ app.session.flash(alert) }}
</div>
{% endif %}
{% endfor %}
{% block content %}
{% endblock %}你能帮我把小树枝代码改成php代码吗?谢谢您:)
发布于 2013-01-10 13:19:26
很简单..。
<?php
if (in_array($alert, array('info', 'success', 'warning', 'error')) {
if (isset($_SESSION["flash"][$alert])) { ?>
<div class="alert alert-<?php echo $alert; ?>">
<button class="close" data-dismiss="alert">×</button>
<?php echo $_SESSION["flash"][$alert]; ?>
</div>
<?php } } ?>https://stackoverflow.com/questions/14251230
复制相似问题