如何从wordpress中的php文件打印到控制台 [英] How to print to console from a php file in wordpress

查看:40
本文介绍了如何从wordpress中的php文件打印到控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 php 文件,它是 wordpress 插件的一部分.我需要调试我们遇到的问题.我想找出变量的值是什么.如何将变量的值打印到控制台?已建议使用 echo 或 chrome 或 firefox 扩展.我无法将 echo 输出到控制台(echo $variablename";),也没有使用 firefox 的 firephp 扩展.

I have a php file which is part of a wordpress plugin. I need to debug an issue we are having. I want to find out what a variable's value is. How can I print the variable's value to console? echo or chrome or firefox extensions have been suggested. I couldn't get echo to output to console (echo "$variablename";) and neither using the firephp extension for firefox.

推荐答案

如果您正在考虑 javascript 控制台,则无法从 PHP 中执行此操作.

If you are thinking about the javascript console, you can not do this from PHP.

您有几个选项可供选择:

You have a few options you could choose from:

为了快速检查变量值,我将使用 var_dump,它还会显示变量的数据类型.当您请求页面时,这将输出到浏览器.

For a quick check for a variables value I would use var_dump, it will also show you the data type of the variable. This will be output to the browser when you request the page.

这篇关于如何从wordpress中的php文件打印到控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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