Welcome Guest, Not a member yet? Register   Sign In
Outputting debug messages
#1

[eluser]pickledegg2[/eluser]
I'm working on a mass of if/else statements, and its getting pretty confusing. Is there a way of getting some messages out to the browser in some way without breaking my cookie functions, as if I do a straight echo it obviously sends headers and causes my cookie operations to crash and burn...

I've got the profiler enabled and it works lovely for my database queries, time taken etc, but I want to stick a load of notice messages into my if/else's.

Thanks.
#2

[eluser]xwero[/eluser]
Do you need all those else/if statements? If they there are to many levels i try to flatten it
Code:
if($sex == 'man')
{
   return 'pants';
}
else
{
   return 'skirt';
}
// vs
if($sex == 'man')
{
   return 'pants';
}

return 'skirt';
#3

[eluser]barbazul[/eluser]
if don't want to breake any headers being sent (such as cookies and the like) instead of outputing your debug, use the built-in log system

[ur]http://ellislab.com/codeigniter/user-guide/general/errors.html[/url]

Code:
log_message('debug', 'The content of my var is: '.print_r($my_var,TRUE));
#4

[eluser]pickledegg2[/eluser]
Thanks for the great answers, I could probably refine my code slightly if I really thought about it, and as for the logging, what a gem, never knew about that!

ps Barbazul great beard.




Theme © iAndrew 2016 - Forum software by © MyBB