How to print to console from a php file in wordpress

php, wordpress

Solution

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

You have a few options you could choose from:

- echo

- var_dump

- create a log file

- xdebug

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.

Problem

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.

Original source

Related problems