ThinkPHP5不让变量解析

71 阅读1分钟

学习Think5的时候,都遇到过这样一个问题,那就是花括号{}会让变量解析,当我们不想让变量解析时怎么办!其实很简单,只需要在变量的前后加一个标签literal把变量给包起来,如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

    <h1>这是文件 view/index/index.html</h1>

    <p>{$email|default="您没有输入邮箱"}</p>

{literal}
    {$email}
{/literal}

</body>
</html>