首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >向php发出警告bootstrap coding twig

向php发出警告bootstrap coding twig
EN

Stack Overflow用户
提问于 2013-01-10 13:15:33
回答 1查看 591关注 0票数 0

我有一些人的代码,他们使用twig而不是php来创建警报引导程序,我会将其更改为php编码,这就是twig编码:

代码语言:javascript
运行
复制
            {% for alert in [ 'info', 'success', 'warning', 'error'] %}
            {% if app.session.hasFlash(alert) %}
            <div class="alert alert-{{ alert }}">
                <button class="close" data-dismiss="alert">&times;</button>
                {{ app.session.flash(alert) }}
            </div>
            {% endif %}
            {% endfor %}

            {% block content %}
            {% endblock %}

你能帮我把小树枝代码改成php代码吗?谢谢您:)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-10 13:19:26

很简单..。

代码语言:javascript
运行
复制
<?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">&times;</button>
        <?php echo $_SESSION["flash"][$alert]; ?>
    </div>
<?php } } ?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14251230

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档