Question:
Can PHP variables be accessed from JavaScript?
Answer:
Directly, it is not possible to access PHP variables in JavaScript.
Implementation:
To bridge the gap, you can:
Echo PHP Variable to JavaScript:
<script type="text/javascript"> var php_var = "<?php echo $php_var; ?>"; </script>
Note:
The above is the detailed content of Can JavaScript Directly Access PHP Variables?. For more information, please follow other related articles on the PHP Chinese website!