CakePHP debug () doesn't work, but Debugger :: dump () is fine
Since PHP4 and Cake 1.3 I've used debug($data);
to debug things like model inference in CakePHP.
However, since upgrading to PHP5.4, I've noticed that it debug($data)
doesn't always work. For example, today I made a simple $data = $this->Model->find('all');
one and the content debug($data);
appears to be empty. No error, just a link in the HTML output that I was calling debug and the line number and then no output.
However, if I run Debugger::dump($data);
in the same find, it works find and I see all the output.
Seems to only happen when it $data
has a significant amount of data (say 100+ records), but I've worked with datasets of this size up to PHP5.4 and never had any problems or errors, inline or in the apache / php logs indicating there is a memory problem and I have a debug value of 3.
Does anyone know why this is? I can easily start using Debugger::dump($data);
, but this is a little overkill to try every time and I would like to know why I can no longer use deubg();
.
source to share
This can happen with non-utf8 encoded data in your db records - if the rest of your application is UTF-8.
debug()
will just output "nothing". var_dump()
, print_r()
And other internal methods php have yet to print the output data.
You can usually convert them to utf8 using iconv (), etc.
source to share