Ever since PHP4 and Cake 1.3 I have been using debug($data); to debug things such as model output in CakePHP.
However, since upgrading to PHP5.4, I have noticed that debug($data) doesn’t always seem to work. For example, today I did a straightforward $data = $this->Model->find('all'); and the contents of debug($data); appears to be empty. No error, just a reference in the HTML output to the fact that I called debug and the line number and then no debug output.
However, if I run Debugger::dump($data); on the exact same find, it works find and I see the entire output.
It seems to only be happening when $data has a significant amount of data (say, 100+ records), but I worked with datasets this size prior to PHP5.4 and there was never a problem and there are no errors, inline or in the apache/php logs indicating that there are any memory issues and I have debugging set to 3.
Does anyone have any idea why this is? I can obviosly starting using Debugger::dump($data); easily but it’s just a little extra to have to try out each time and I’d like to know why I can’t just use deubg(); anymore.
This can happen with non-utf8 encoded data in your db records – if the rest of your application is UTF-8 that is.
debug()will then just output “nothing”.var_dump(),print_r()and other php internal methods should still print the output, though.You can usually re-encode them to utf8 using iconv() etc.