Is there a way to pass every variable in a controller action, to the view automatical |
Is there a way to pass every variable in a controller action, to the view automatical
So instead of PHP Code: <?php PHP Code: <?php And I can echo $test in the view and the word "hello" appears as the variable is passed automatically to the view without me having to manually pass it myself.
this isn't quite how i do it but you could do something like:
PHP Code: <?php PHP Code: $data['test'] = 'test'; What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Is this what you want to do:
http://php.net/manual/en/function.get-defined-vars.php This function returns a multidimensional array containing a list of all defined variables, be them environment, server or user-defined variables, within the scope that get_defined_vars() is called. Then you can pass that to the view (or, I dunno, make it a global variable and access it that way) I don't recommend any of this, setting up a $data variable doesn't seem like a burden worth working around... |
Welcome Guest, Not a member yet? Register Sign In |