Javascript Result Into Php. JavaScript can display data in different ways. Notice the quotes around the PHP tags.
Use json_encode to turn your PHP array into a valid javascript object. Passing a variable from PHP to JavaScript is actually very easy. This example uses form element and GETPOST method to pass JavaScript variables to PHP.
Example PHP Variables to JavaScript.
Passing a variable from PHP to JavaScript is actually very easy. Notice the quotes around the PHP tags. This will result in a string value in JavaScript which you may need to convert for use in your scripts. If you perform the echo from that testphp page there naturally won.