A developer wants to pass user profile data to a dashboard view in CodeIgniter. The most efficient approach is to use ________.

  • $this->load->view('dashboard', $data);
  • $this->load->view('dashboard', compact('data'));
  • $this->load->view('dashboard', ['data' => $data]);
  • $this->load->view('dashboard', array('data' => $data));
In CodeIgniter, the most efficient way to pass data to a view is by using an associative array. The option 3 demonstrates the correct syntax by passing the data directly within the load->view function. This approach keeps the code concise and readable.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *