How to use javascript in php

Below code show you how to use javascript in php.


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>using script in php tags</title>
</head>
<body>
<h2>using script in php tags</h2>
<?php
echo"using script in php tags", "<script>alert('this is javascript alert');</script>";

/* alert msg by using variable.

$var = "this is javascript alert 2";
echo"<script>alert('$var');</script>";
*/
?>
</body>
</html>