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 :: Write a php program to perform sum of two numbers 
Php :: add floater to open a modal in wordpress 
Php :: yii2 sendemail extension 
Php :: quitar html con laravel 5 
Php :: php define variables from array associative 
Php :: this app is not allowed to query for scheme fb-messenger" 
Php :: change default route laravel 
Php :: laravel select only one word from string 
Php :: in php how to check md5 password 
Php :: get url parameter laravel 5.2 constructor 
Php :: REFERRER CODEIGNITER 3 
Php :: Drupal 9 entity.repository load entity by UUID 
Php :: laravel custom validation 
Php :: scirvere su file php 
Php :: intellisense in visual studio code for php-oop 
Php :: php compress csv file 
Php :: wp_query start from second post 
Php :: access model in config laravel 
Php :: livewire custom attribute 
Php :: Save image to custom meta box 
Php :: strpos 
Php :: find auth laravel 
Php :: ?: php 
Php :: get the matched value from 2 array in php 
Php :: mysqli connect error 
Php :: laravel collection pop 
Php :: wp_delete_attachment unlink 
Php :: PHP exif_read_data() 
Php :: workpress change page title from shortcode 
Php :: php print html code 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =