In javascript, I can print to the debug console using
console.log("Message here");
I'm now writing a php script, and would like to print to the debug console. Using the above code doesn't work in php. It seems I need to use either echo or some other command but I need the output to appear inside the output console, not the browser window.
The echo command is used in PHP to print any value to the HTML document. Use <script> tag inside echo command to print to the console.
Use JavaScript console. log() and the json_encode() Function to Write to the Console in PHP. We can use the json_encode() function along with the JavaScript console. log() to write to the console in PHP.
You should use the console. log() method to print to console JavaScript. The JavaScript console log function is mainly used for code debugging as it makes the JavaScript print the output to the console. To open the browser console, right-click on the page and select Inspect, and then click Console.
<?php echo '<script>console.log("Your stuff here")</script>'; ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With