Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to echo (or print) to the js console with php

Tags:

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.

like image 217
OB7 Avatar asked May 20 '15 18:05

OB7


People also ask

How can I print to console in PHP?

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.

Can PHP write 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.

How do you print to console in JavaScript?

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.


1 Answers

<?php    echo '<script>console.log("Your stuff here")</script>'; ?> 
like image 104
arjabbar Avatar answered Sep 22 '22 06:09

arjabbar