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 :: remove array element in php 
Php :: php superglobal 
Php :: php mess detector 
Php :: Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in 
Php :: route params link laravel 
Php :: error repoerting in php 
Php :: undefined method JeroenNotenLaravelAdminLteHelpersMenuItemHelper::isSearchBar() 
Php :: taxonomy acf 
Php :: browser detection php 
Php :: how validate data if is exist must not be empty in laravel 
Php :: To store data in the session Laravel 
Php :: saveAll get all id save cakephp 
Php :: aws s3 laravel package 
Php :: laravel/framework[v8.75.0, ..., 8.x-dev] require league/flysystem ^1.1 - satisfiable by league/flysystem[1.1.0, ..., 1.x-dev]. 
Php :: wordpress show notice 
Php :: laravel token logout 
Php :: [!] No podspec found for package_name in path_to_package... 
Php :: upload_max_filesize 
Php :: laravel get current action name 
Php :: program-generate-random-alphabets using php 
Php :: how to change javascript value to php value 
Php :: br php 
Php :: change returning datetime timezone to recalculate with user timezone laravel 
Php :: json whereIn laravel 
Php :: How do I check if a string contains a specific word? 
Php :: php var dump into string 
Php :: laravel tinker generate password 
Php :: convert query result to array php 
Php :: php serialize array 
Php :: how to bulk insert array into sql php 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =