如何检查Smarty中是否存在变量?

时间:2022-12-04 08:29:43

I'm using Smarty template engine.

我正在使用Smarty模板引擎。

I'm doing a simple login page. I set a variabile named error with a message if there are some problems, but IF NOT I get:

我正在做一个简单的登录页面。如果有一些问题我设置了一个带有消息的变量命名错误,但如果不是我得到:

Notice: Undefined index: error

How could I check if this variable exists?

我怎么能检查这个变量是否存在?

I only do:

我只做:

{if $error}<h1>{$error}</h1>{/if}

thanks

谢谢

3 个解决方案

#1


38  

isset() - smarty - php

isset() - smarty - php

isset($error)

#2


49  

There you go!

你去!

{if isset($error)}

#3


0  

This is short :) No warnings or errors.

这很简短:)没有警告或错误。

{if $error}

#1


38  

isset() - smarty - php

isset() - smarty - php

isset($error)

#2


49  

There you go!

你去!

{if isset($error)}

#3


0  

This is short :) No warnings or errors.

这很简短:)没有警告或错误。

{if $error}