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 output

<?php
  
  $message = "Thanks..";
  
  echo "<script>console.log('".$message."');</script>";
  
?>
    
Output: Thanks..
Comment

php console log

echo("<script type='text/javascript'> console.log($msg);</script>");
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

php print to console

<script>
    console.log(<?= json_encode($foo); ?>);
</script>
Comment

php console log

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

php console print

$a = array(
 null => 'a',
 true => 'b',
 false => 'c',
 0 => 'd',
 1 => 'e',
 '' => 'f'
);

echo count($a), "
";
Comment

PREVIOUS NEXT
Code Example
Php :: string to slug php 
Php :: woocommerce redirect shop page 
Php :: choose a random word from an array php 
Php :: Wordpress disable plugin or theme installation 
Php :: codeigniter get user ip 
Php :: php self submit 
Php :: laravel convert timestamp to date 
Php :: test a single file laravel 
Php :: check table exists in db laravel 
Php :: logout php 
Php :: laravel collection toArray 
Php :: laravel where is null 
Php :: strtolower php 
Php :: php remove first and last char 
Php :: get price woocommerce product 
Php :: php split string by enter 
Php :: laravel collection shuffle 
Php :: woocommerce custom sale banner, sash 
Php :: substr() php 
Php :: php get first and last day of previous month 
Php :: symfony get current datetime 
Php :: laravel created_at migration 
Php :: php create 404 error 
Php :: laravel middleware route group 
Php :: reindex array php 
Php :: Laravel factory avatars 
Php :: laravel php short if 
Php :: collection pluck remove duplicates 
Php :: php array to js 
Php :: laravel access controller method from another controller 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =