Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php console log

// 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!');
?>
Comment

php console log

echo("<script type='text/javascript'> console.log($msg);</script>");
Comment

console.log in php

/*
console.log in php
*/

<?php
	function consoleLog($message) {
		echo '<script type="text/javascript">' .
          'console.log(' . $message . ');</script>';
	}

	consoleLog('Hello, greppers!');
?>
Comment

console log in php

<?php 
function console_log($object){
    echo "<script>console.log(".json_encode(var_export($object, true)).");</script>";
}
console_log('wow!');

?>
Comment

php console log

// 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!');
?>
Comment

console.log for php

<?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 
Comment

console_log in php

<?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;
}
Comment

php console log

<?php
	function consoleLog($msg) {
		echo '<script type="text/javascript">console.log('. $msg .');</script>';
	}
	consoleLog("'Hello world!'");
?>
Comment

PREVIOUS NEXT
Code Example
Php :: string length php 
Php :: install symfony ubuntu 
Php :: disable SSL check in PHP cURL 
Php :: Detecting russian characters on a form in PHP 
Php :: stream_set_blocking 
Php :: I cannot login to my CPanel hosted Laravel Application, my SSL has expired 
Php :: php show number 4 digit 
Php :: Warning: mysqli_error() expects exactly 1 parameter, 0 
Php :: php create Hmac sha256 
Php :: .htaccess for laravel in hostinger 
Php :: laravel child relation order by desc 
Php :: laravel collection implode 
Php :: unique sql queries laravel 
Php :: php access json object 
Php :: symfony get api paths 
Php :: carbon 2 days ago 
Php :: composer create-project laravel/laravel --prefer-dist laravel-bootstrap 
Php :: errno: 150 foreign key constraint is incorrectly formed laravel 8 
Php :: wp_query item count 
Php :: php get all values from associative array 
Php :: get cart item by cart item key woocommerce 
Php :: log magento 2.4.3 
Php :: php sha512 
Php :: insert php variable css 
Php :: php iterate through array 
Php :: php check array is not associative 
Php :: how to convert string word to lowercase in php 
Php :: php convert hex to rgba 
Php :: diff for seconds laravel carbon 
Php :: concat() function using laravel eloquent query 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =