<?php
$php_data = "abc";
?>
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pass variables and data from PHP to JavaScript</title>
</head>
<body>
<script>
js_data = '<?php echo $php_data ?>'; // js_data = 'abc';
alert(js_data);
</script>
</body>
</html>
<!--
*** Page content will be
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pass variables and data from PHP to JavaScript</title>
</head>
<body>
<script>
js_data = 'abc'; <<<<<<<<<<<<<<<<<<
alert(js_data);
</script>
</body>
</html>
-->