Adventskalender Day 2 – PHP Debugging in Browser Console

02

Debugging in PHP has many functions, but it is also useful if you have a technic to debug in console of a browser. For this requirement there are a lot of libraries and enhancements. Often they are oversized and not the fastest way to reach the goal of an easy output of a variable. Debugging in UIs or on customer side is also a good point for debugging in the console. This article will demonstrate a small snippet to create a simple solution to debug PHP in a console of your browser.

debug-in-console

I often use a simple variant, see the snippet below. I use this often for the debugging of customer problems or in a development environment to not destroy the UI. The function works in all major browsers and also with the add-on Firebug in Firefox, see the screenshots in Chrome and Firebug.

Javascript und PHP

The console use always the javascript function console() to display the content. It is easy to include this for the following function to create the output. I think it is easy to understand the function and the values for debugging will be passed with the variable $data.

[/crayon]

debug-in-console-ff

The view is possible with different types, like array, string or object. Also I have include the function inside my debugging helper plugin Debug Objects for WordPress, so it is easy to use.

Be excited for tomorrow’s MarketPress Adventskalender‘s door: A litte code-snippet.

Post Sharing

Author Avatar

Alpinist, Cyclist, Optimist. I develop and support solution, primarily with SAP Business Software as Software Architect at Carl Zeiss AG and I help Companies make WordPress-based software and solutions with a great team at the Inpsyde GmbH.

Also Interesting

slack-blog

New Plugin: Slack Connector - Connect WordPress, WooCommerce and Slack

by Michael Firnkes

Initially we merely wanted to optimize our own Slack-processes. With automated notifications from our MarkettPress shop, the blog and our forums. The resul ...

Read more
vip

Inpsyde is the first WordPress.com VIP partner in Germany

by Michael Firnkes

Automattic has given us the title of WordPress.com VIP Service Partner, the first in Germany, Austria and Switzerland. Worldwide, there are only eleven com ...

Read more
wooexperts

Inpsyde is a WooExperts Gold Partner of WooCommerce

by Michael Firnkes

A few weeks ago, Inpsyde GmbH with MarketPress became a certified WooExperts Gold Partner. This is confirmation from WooThemes of our agency’s know-h ...

Read more
backwpup

BackWPup Pro: Secure WordPress Backup with Google Drive

by Michael Firnkes

The Pro version of our BackWPup plugin supports the backup of WordPress databases and files to Google Drive. But how do you set something like that up? And ...

Read more

Comments

2 Comments

  1. #1

    nice 🙂

    here an another script

    [/crayon]

    • #2

      @Markus: Thanks for the comment. In the plugin Debug Objects is also for this topic a solution, if you use the plugin.

      [/crayon]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">