I am new to PHP. I want to pass the php variable into my javascript file. But it was not converted. I already defined the value of $val in php file. I write following code in my index.js file;
var val = "<?php echo $val ?>";
console.log(val);
but my console shows output as : <?php echo $val ?>. It is not taking the php variable value. Any help?
.jsfiles..jsfile? It says you're supposed to put it in the JavaScript segment of a PHP script.<script>tag. That solved my issue.