“Output konsol PHP” Kode Jawaban

Log Konsol PHP

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

Log Konsol PHP

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

Output konsol PHP

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

Log Konsol PHP

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

PHP Print to Console

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

PHP Console Print

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

echo count($a), "\n";
Shiny Skylark

Jawaban yang mirip dengan “Output konsol PHP”

Pertanyaan yang mirip dengan “Output konsol PHP”

Lebih banyak jawaban terkait untuk “Output konsol PHP” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya