Question : php console log
Answered by : kaotik
// Assuming you are wishing to log to the JS Console...
<?php function consoleLog($msg) { echo '<script type="text/javascript">' . 'console.log(' . $msg . ');</script>'; } consoleLog('Hello, console!');
?>
Source : | Last Update : Sat, 14 Mar 20
Question : php console log
Answered by : oscar-capraro
echo("<script type='text/javascript'> console.log($msg);</script>");
Source : | Last Update : Thu, 25 Feb 21
Question : console.log in php
Answered by : ankur-prajapati
/*
console.log in php
*/
<?php function consoleLog($message) { echo '<script type="text/javascript">' . 'console.log(' . $message . ');</script>'; } consoleLog('Hello, greppers!');
?>
Source : | Last Update : Mon, 18 May 20
Question : console php
Answered by : john-pinto
//display message in console
<?php function console_log($msg) { echo '<script>' . 'console.log("'.$msg .' ")</script>'; } console_log("Hi there!");
?>
Source : | Last Update : Tue, 13 Oct 20
Question : console log in php
Answered by : omar-faruk
<?php
function console_log($object){ echo "<script>console.log(".json_encode(var_export($object, true)).");</script>";
}
console_log('wow!');
?>
Source : | Last Update : Thu, 07 Oct 21
Question : php console log
Answered by : httpsgithubcomgarzj
// A little correction / improvement to @Kaotik's answer:
<?php function consoleLog($msg) { echo '<script type="text/javascript">console.log(' . str_replace('<', '\\x3C', json_encode($msg)) . ');</script>'; } consoleLog('Hello, console!');
?>
Source : | Last Update : Wed, 17 Jun 20
Question : console_log in php
Answered by : average-ape-8wazfnfygvi2
<?php
function console_log($output, $with_script_tags = true) { $js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) .
');'; if ($with_script_tags) { $js_code = '<script>' . $js_code . '</script>'; } echo $js_code;
}
Source : https://stackify.com/how-to-log-to-console-in-php/ | Last Update : Wed, 19 Aug 20
Question : console.log for php
Answered by : omar-faruk
<?php
function console_log($output, $with_script_tags = true)
{ $js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) . ');'; if ($with_script_tags) { $js_code = '<script>' . $js_code . '</script>'; } echo $js_code;
}
#Let's use this :)
$name = "Omar Faruk"; // string type variable
console_log($name); // "Omar Faruk"
console_log(gettype($name)); // string
// now go to the browser and check the console
Source : https://www.atatus.com/blog/how-to-log-to-console-in-php-and-why-should-you-do-it/ | Last Update : Mon, 19 Sep 22
Question : php console log
Answered by : pedro-c914jbp93vvw
<?php function consoleLog($msg) { echo '<script type="text/javascript">console.log('. $msg .');</script>'; } consoleLog("'Hello world!'");
?>
Source : | Last Update : Sat, 08 Oct 22