5

How can I print out some debug output, like the contents of an array variable? I'm using cakephp and eclipse and can't seem to be able to do this. I am not talking about logging errors, just print some variable value. It might be obvious and really easy to do, but I can't find a way to do it.

Thank you

3 Answers 3

17

There are no dumb questions for someone learning. So here are your options :

  • Anywhere in your code, place the following statement debug($var);. This works in Controllers/Views and Models as well.

  • Alternative: use CakeLog::write(LOG_DEBUG, "..."); to log debug values

  • To be complete, one should install the very helpful DebugKit plugin. Get it from here

Sign up to request clarification or add additional context in comments.

1 Comment

It's worth mentioning in your answer that debug level must be set to 2 in app/config/core.php Configure::write('debug', 2);
7

First check in your core.php file inside config folder ..

debug mode is 2 or not..

Configure::write('debug', 2);

and you can print data , array ,

like this:-

debug($data);
pr($data);
print_r($data);

we have debuging kit also for cakephp, By this you can see your request, session, $this->data values,, url,

Comments

4

All you have to do is to use cakephp debug function like

debug($arrayname);

Before that you have to set debug mode to 2 at core.php under app/config folder

Here is more detail about the debug

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.