CakePHP debug() 不起作用,但 Debugger::dump() 很好 [英] CakePHP debug() isn't working but Debugger::dump() is fine

查看:15
本文介绍了CakePHP debug() 不起作用,但 Debugger::dump() 很好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 PHP4 和 Cake 1.3 开始,我一直使用 debug($data); 来调试诸如 CakePHP 中的模型输出之类的东西.

Ever since PHP4 and Cake 1.3 I have been using debug($data); to debug things such as model output in CakePHP.

然而,自从升级到 PHP5.4 后,我注意到 debug($data) 似乎并不总是有效.比如今天我做了一个简单的$data = $this->Model->find('all');debug($data); 似乎是空的.没有错误,只是在 HTML 输出中引用了我调用调试和行号然后没有调试输出的事实.

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.

但是,如果我在完全相同的 find 上运行 Debugger::dump($data); ,它会起作用 find 并且我会看到整个输出.

However, if I run Debugger::dump($data); on the exact same find, it works find and I see the entire output.

这似乎只发生在 $data 有大量数据(比如 100 多条记录)时,但我在 PHP5.4 之前使用过这种大小的数据集,从来没有问题并且没有错误,内联或 apache/php 日志表明存在任何内存问题,并且我已将调试设置为 3.

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.

有人知道这是为什么吗?我可以很容易地开始使用 Debugger::dump($data); ,但每次都需要尝试一些额外的东西,我想知道为什么我不能只使用 deubg(); 不再.

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.

推荐答案

这可能发生在您的 db 记录中的非 utf8 编码数据 - 如果您的应用程序的其余部分是 UTF-8.debug() 然后将只输出nothing".var_dump()print_r() 和其他 php 内部方法应该仍然打印输出.

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.

您通常可以使用 iconv() 等将它们重新编码为 utf8.

You can usually re-encode them to utf8 using iconv() etc.

这篇关于CakePHP debug() 不起作用,但 Debugger::dump() 很好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆