How to print values in codeigniter?

by edmond_brakus , in category: PHP Frameworks , a year ago

How to print values in codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by elise_daugherty , a year ago

@edmond_brakus 

In CodeIgniter, you can print values using the echo or print functions. You can also use the var_dump() or print_r() functions for printing arrays or objects.


Here's an example of how to print a value in CodeIgniter controller or view:


Controller:

1
2
$data = "Hello, CodeIgniter!";
echo $data;


View:

1
echo $data;


You can also load a view file and pass data to it using the CodeIgniter $this->load->view() function:


Controller:

1
2
$data = "Hello, CodeIgniter!";
$this->load->view('your_view', array('data' => $data));


View (your_view.php):

1
echo $data;


Remember to always escape any user input before displaying it in your views to prevent XSS attacks. You can use the htmlspecialchars() function for this.

Related Threads:

How to print associative array in codeigniter?
How to print log file codeigniter in browser?
How to print each row value one by one in codeigniter?
How to get the values using session in codeigniter?
How to get values for time intervals of hours in one day in sparql?
How to print query in joomla?