Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法改变 smarty 核心{if $foo}使其使用isset()and $foo|default:$foo2?
{if $foo}
isset()
$foo|default:$foo2
我问这个的原因是因为我收到了 PHP 警告消息。
我知道我可以做 {if isset($foo)} 虽然在没有 isset() 的情况下写这个很干净。
在 {if} 中,表达式不应抛出任何通知。(至少曾经是这样)
您可以编写一个简单的前置过滤器(使用正则表达式)查找 "{if $foo}" 并将其转换为等效的{if !empty($foo)}.
{if !empty($foo)}
如果您觉得遇到了错误/需要改进,请在错误跟踪器上分享您的想法。