i am trying to use the value of a php variable as javascript variable within my zend framework 3 based project. But, it is not rendering properly. Sample code is given below that i tried.
<?php
$this->inlineScript()->captureStart();
echo <<<JS
function abc(){
var a='<?php echo $name?>';
......
}
JS;
$this->inlineScript()->captureEnd();
?>
Here, it is printing as it instead of rendering the value of $name. Is there any way to do so like we can do using within plain script tag like below.
<script type='text/javascript'>
function abc(){
var a='<?php echo $name?>';
}
</script>