CodeIgniter - Calling a function from inside a view

后端 未结 7 1465
长情又很酷
长情又很酷 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:03

    you can declare a function this way inside views:

    $myfunction = function_that_do_something( ) {
    }
    
    // then call as you want
    $myfunction( );
    

    the only thing is that you cannot acces the variables from the function -> simply pass them to the function

提交回复
热议问题