{% 闪光 %}
这{% flash %} 和{% endflash %} 标签将呈现存储在用户会话中的任何 flash 消息,由Flash PHP类。这message 里面的变量将包含 flash 消息文本,里面的标记将重复多个 flash 消息。
<ul>
{% flash %}
<li>{{ message }}</li>
{% endflash %}
</ul>
您可以使用type 表示 flash 消息类型的变量 —success,error,info 或者warning.
{% flash %}
<div class="alert alert-{{ type }}">
{{ message }}
</div>
{% endflash %}
您还可以指定type 过滤给定类型的 flash 消息。下一个例子将只显示success 消息,如果有error 消息它不会被显示。
{% flash success %}
<div class="alert alert-success">{{ message }}</div>
{% endflash %}
设置即显信息
可以设置闪信Components 或在页面或布局内PHP 部分 与Flash 班级。
<?php
function onSave()
{
// Sets a successful message
Flash::success('Settings successfully saved!');
// Sets an error message
Flash::error('Error saving settings');
// Sets a warning message
Flash::warning('There was a problem but no worries');
// Sets an informative message
Flash::info('Just a heads up about the settings');
}