Is there any way to var_dump a variable?

codeigniter

Solution

Or you can use CI's logging facility:

log_message('debug', var_export($some_variable));

And check your application's log folder, usually application/logs. You can do that anywhere - model or controller.

NB - Check application/config/config.php to ensure logging is enabled. It's not simply a on/off switch, you can choose the level of logging messages to record. Set to all for development but to errors only on production, for example.

Problem

I want to var_dump a variable to debug my database operation. I don't want to install any debugger so I used var_dump($result) in my model. It output the errors. ``` This page contains the following errors: error on line 1 at column 1: Document is empty Below is a rendering of the page up to the first error. ``` How to do it?

Original source