未定义的变量解决方案?? [英] Undefined Variable Solution??
问题描述
早上好,
我有一组变量通过CodeIgniter的MVC设置传递给表单,但是我试图避免重复表单元素所有可能的。
但是,当我尝试在添加上构建输入字段时,我得到未定义的变量错误(有充分的理由)。表格。
我知道我可以复制表单元素,一个是$ result [''data'']而另一个没有,但我真的不喜欢。
您如何建议我构建下面的表单,以便我只传递一次form_xxxx()函数?
Good Morning,
I have a set of variables being passed to a form via CodeIgniter''s MVC setup, however I am trying to keep from duplicating the form elements if at all possible.
However, I am getting undefined variable errors (for good reasons) when trying to build the input fields on the "add" form.
I know I can duplicate the form elements, one with the $result[''data''] and one without, but I would really prefer not.
How would you suggest I build the form below so that I only pass the form_xxxx() functions once?
推荐答案
结果[''数据'']和没有,但我真的不喜欢。
你怎么样?建议我构建下面的表单,以便我只传递一次form_xxxx()函数?
result[''data''] and one without, but I would really prefer not.
How would you suggest I build the form below so that I only pass the form_xxxx() functions once?
AHA !!!现在我懂了。事实证明,您可以使用那些''''来阻止报告错误。
有更好的解决方案吗?像内部if语句?
AHA!!! Now I get it. Turns out you can use those ''@'' to stop errors from being reported.
Is there a better solution for this? Something like an internal if statement?
查看三元运算符,可以轻松地为变量设置默认值(如果它尚不存在)。使用@很贵。
Check out the ternary operator, to easily set a default value to your variable if it doesn''t already exist. Using @ is expensive.
这篇关于未定义的变量解决方案??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!