Communication

PHP to Javascript on initial page load

<script>
var foo = <?php echo json_encode(array('bar1'=>'This''bar2'=>'Works'))?>;
document.write(foo.bar1+' '+foo.bar2);
</script>
Output