CodeIgniter - Calling a function from inside a view

后端 未结 7 1484
长情又很酷
长情又很酷 2021-01-06 13:25

Is it possible to call a function which is located in a controller from a view?

This is what i have in my controller, as an example

function checkKey         


        
7条回答
  •  逝去的感伤
    2021-01-06 14:12

    Views are not meant to call controller actions. Reverse your logic, call that function in the controller and set it to a variable you sent to the view. Then you can have the if statement check that variable in your view template.

    If that doesn't work for you, maybe a helper is what you need: https://www.codeigniter.com/user_guide/general/helpers.html

提交回复
热议问题