我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Smarty检查是否未定义

i am getting errors if smarty variable is undefined.

Here is the code:

< input type="text" value="{$data.allKeywords} id='keyId' />

I am getting the error: Undefined index: allKeywords.

I know the variable - $data.allKeywords is undefined but should it not ignore it if a variable is undefined?

Is there a way to check if it is undefined in smarty template files only ?

Thanks.

You can wrap it in a Smarty if statement

<input type="text" value="{if $data.allKeywords}{$data.allKeywords}{/if} "id='keyId' />

近期文章

  • PHP中的PARSE XML
  • PHP查询生成器/报告器
  • Java不用循环语句,只使用substring是否可以实现滚动字符串
  • Jquery连续ajax请求
  • 为什么在CakePHP中使用正则表达式(必须是CakePHP)
  • 使用xsl什么都不显示
  • 在Kohana中使用自定义类3
  • PHP:直接访问对象数组中的元素
  • 特定端口的php参数
  • 使C函数可用于php
  • 搜索表单以向外部站点提交查询
  • 为什么我的php移动文件脚本实际上没有移动文件?
  • 遇到jquery.post()和php curl的问题
  • 如何在WordPress 3中锐化后缩略图
  • 如何将RSS提要加入其中? (来自php)
  • 包含php变量的$ _POST []数组错误
  • 需要帮助理解一对一的Doctrine
  • 如何在php中将多维数组传递给函数
  • 在使用MVC时如何处理循环中的html?
  • 存储网站偏好的最佳方法是什么?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华