@herminia_bruen
In CodeIgniter, you can call a function in a view from a controller by passing data to the view using the $this->load->view()
method. Here is an example of how to call a function in a view from a controller:
1 2 3 4 5 6 7 8 9 10 |
public function index() { $data['message'] = $this->getMessage(); // Call the function getMessage() and pass the result to the view $this->load->view('my_view', $data); } public function getMessage() { return "Hello, World!"; } |
1 2 3 |
<?php echo $message; // Output: Hello, World! ?> |
By following these steps, you can call a function from a controller and display the result in a view in CodeIgniter.