How to print Console.log in PHP

MDN web docs explain console.log() very well.

The console.log() method outputs a message to the web console. The message may be a single string (with optional substitution values), or it may be any one or more JavaScript objects.


If you are a Frontend Developer or who use web browser, you need to know well about this method. As a junior web dev, I also love printing with this method but sometime I meet obstacle.

My company has a website that made by Wordpress. So i need to fix bug in in PHP environment the first thing i need to find is this.

“How can i debug with console.log()

For this reason, I decided to wrap up that method today.

The principle is simple. PHP is a backend environment, it draws code into pieces.

If we want to write console.log( ) like above then,

So easy right? If it is little hard to understand than you can break down it.

This way, you will be able to understand the principle of PHP to output pieces one by one.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store