CodeIgniter debug function: How can i display/debug formated value of any variable from controller?
Is there any built-in debug function for codeigniter to use in controller?
In cakephp there is debug($variable) that one can use in controller.
I can use var_dump($variable); or print_r($variable);
But is there any built-in debug function 开发者_运维问答for codeigniter to use in controller to get formatted result of any variable?
The way I usually handle this is wherever I want to debug a variable.
...
echo "<pre>";
die(print_r($var, TRUE));
...
This gives you a nicely formatted version of your variable contents because it retains the formatting when inside of the <pre>
tag.
So instead of
Array ( [0] => "value zero" [1] => "value 1" )
you get
Array
(
[0] => "value zero"
[1] => "value one"
)
etc...
Not sure how much more formatted you can get, unless you're looking for color schemes and animations in your debug statements.
You can use Fire Ignition (with FireBug and FirePHP, or ChromePHP if you use FF instead of Chrome)
http://codeigniter.com/wiki/Fire_Ignition/
http://codeigniter.com/user_guide/general/errors.html http://codeigniter.com/user_guide/general/profiling.html
https://github.com/ccampbell/chromephp
精彩评论