2015-09-30 15:15
浏览 26


Should I be checking for if a variable is set in the view file ? I mean we are controlling what data is being sent to the view, so ideally it shouldn't be necessary.

And if we check a variable and find that it's not set then what should we do ? Redirect to 404 ? Then again redirecting from view doesn't seem right.

What are the possibilities of a view being loaded without a particular variable ?

I am working in codeigniter.

图片转代码服务由CSDN问答提供 功能建议

我是否应该检查视图文件中是否设置了变量? 我的意思是我们正在控制要发送到视图的数据,所以理想情况下它不是必需的。

如果我们检查一个变量并发现它没有设置那么我们应该怎么做 做什么? 重定向到404? 然后再次从视图重定向似乎不正确。


我正在工作 在codeigniter。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douhuan1497 2015-09-30 15:54

    Logic belongs to controllers. You are passing data also from controllers to views.

    The best way is to check in your controller, and if it's not exists, do the redirect then.

    Views are just visual representation of your data, no logic belongs to there.

    打赏 评论

相关推荐 更多相似问题