<?php
header("Content-type: application/javascript");
?>
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<?php
$variable=10;
?>
<script>
var myVar = "<?php echo $variable; ?>";
alert(myVar);
</script>
</body>
</html>
this is my source code and it is not working. My concern is converting the php variable as javascript variable..The alert displays the entire line as a string instead of printing the value...Have tried json function as well.No use.what should I be doing?