PHP передать вариабель JS
<script>
'var name = <?php echo json_encode($name); ?>;
</script>'
Lucky Lynx
<script>
'var name = <?php echo json_encode($name); ?>;
</script>'
//passing PHP variable to JavaScript
var myJSVar = <?php echo json_encode($myPHPVar); ?>;