console php
//display message in console
<?php
function console_log($msg) {
echo '<script>' .
'console.log("'.$msg .' ")</script>';
}
console_log("Hi there!");
?>
console php
//display message in console
<?php
function console_log($msg) {
echo '<script>' .
'console.log("'.$msg .' ")</script>';
}
console_log("Hi there!");
?>
php print to console
<script>
console.log(<?= json_encode($foo); ?>);
</script>
php console log
function debug($var, $die = false, $trace = true, $show_from = true)
{
//Trick to avoid html corruptions
echo '</select>';
echo '</script>';
// BackTrace
$stack = '';
$i = 1;
$trace = debug_backtrace();
array_shift($trace);
foreach ($trace as $node) {
if (isset($node['file']) && ($node['line'])) {
$stack .= "#$i " . $node['file'] . "(" . $node['line'] . "): ";
}
if (isset($node['class'])) {
$stack .= $node['class'] . "->";
}
$stack .= $node['function'] . "()" . PHP_EOL;
$i++;
}
$out[] = '<pre style="background-color:#CCCCCC">';
if ($show_from) {
$calledFrom = debug_backtrace();
$out[] = '<strong>' . substr(str_replace(dirname(__FILE__), '', $calledFrom[0]['file']), 1) . '</strong>';
$out[] = ' (line <strong>' . $calledFrom[0]['line'] . '</strong>)';
}
$out[] = htmlspecialchars(print_r($var, true));
if (is_object($var)) {
$out[] = '-------- Class methods --------';
$out[] = print_r(get_class_methods(get_class($var)), true);
}
if ($trace) {
$out[] = '-------- Backtrace --------';
$out[] = $stack;
}
$out[] = '</pre>';
echo implode(PHP_EOL, $out);
if ($die) {
die();
}
break;
}
php console print
$a = array(
null => 'a',
true => 'b',
false => 'c',
0 => 'd',
1 => 'e',
'' => 'f'
);
echo count($a), "\n";
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us