Use the code below to get the value of a php variable passed to a Javascript variable thus allowing you to send a php variable to Javascript.
If the php variable is an array then we need to use json_encode and NOT enclose the php statement in quotes to get that variables value in Javascript.
Try passing a PHP variable to a Javascript function yourself by pressing the button below. Right click this page and VIEW SOURCE to see the code.
Related: how to copy php array to Javascript array.
Although the php code is hidden from the web browser view source, here is the exact php code that is written directly below this pagegraph: <?php $phpvariable = 'Hi there from PHP!!';?>