Created
August 22, 2013 13:56
-
-
Save jmariano13/6307503 to your computer and use it in GitHub Desktop.
PHP JAVASCRIPT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Example: 1 http://stackoverflow.com/questions/4287357/access-php-variable-in-javascript | |
| <script type="text/javascript"> | |
| var php_var = "<?php echo $php_var; ?>"; | |
| </script> | |
| //Example: 2 http://stackoverflow.com/questions/2928827/access-php-var-from-external-javascript-file | |
| <?php $color = "Red"; ?> | |
| <script type="text/javascript">var color = "<?= $color ?>";</script> | |
| <script type="text/javascript" src="file.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| http://stackoverflow.com/questions/4287357/access-php-variable-in-javascript | |
| <script type="text/javascript"> | |
| var something=<?php echo json_encode($a); ?>; | |
| </script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment