title: Codeigniter global variable in view
body: <p>I don't know if the title above is an correct title about my question. </p>
  
  <p>Is there a way to declare a variable which we can access it from anywhere in view without need to redefine it again in each function in controller?</p>
  
  <p>for example in controller file Students.php contains many function that handle the views, take a look below :</p>
  
  <pre><code>public function __construct() {
    parent::__construct();
    $data['count_student'] = $this-&gt;m_data-&gt;allStudent(); // count all students
  }
  
  public function index() {
    $data['content'] = 'view-students';
    $this-&gt;load-&gt;view('frontend/header' , $data);
  }
  
  public function showDetails() {
        $data['content'] = 'view-detail-students';
        $this-&gt;load-&gt;view('frontend/header' , $data);
  }
  </code></pre>
  
  <p>I expected we can access <code>$count_student</code> in both <code>view-students.php</code> and <code>view-detail-student.php</code> without to define <code>$data['count_student'] = $this-&gt;m_data-&gt;allStudent();</code> on each function that handle the view.</p>
  
  <p>Is there possible ways to do that?</p>