<!DOCTYPE html> <html> <head> <title></title> </head> <body> <script type="text/javascript"> //String var s = "<?php echo "test";?>"; console.debug(s); //Integer var i = <?php echo 1?>; console.debug(i); </script> </body> </html>
參考資料:
http://stackoverflow.com/questions/415868/get-variable-from-php-to-javascript