Welcome Guest, Not a member yet? Register   Sign In
Automatically passing controller action variables to the view
#1

I would like a way to automatically pass variables from a controller action to a view just by declaring a variable.

So instead of 

PHP Code:
<?php
class News extends CI_Controller {
        public function index()
        {
                $data['test'] = "hello";
        }

I can have


PHP Code:
<?php
class News extends CI_Controller {
       public function index()
       {
               $test "hello";
       }




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.

Ruby framework Ramaze has this feature, and it makes coding much more pleasant.


Messages In This Thread
Automatically passing controller action variables to the view - by desbest - 06-16-2017, 05:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB