Possible Duplicate:
How to access PHP variables in JavaScript or jQuery rather than <?php echo $variable ?>
Is there any way to get access to a PHP variable in JavaScript?
I have a variable, $a, in PHP and want to get its value in a JavaScript variable.
You can’t, you’ll have to do something like
You can also load it with AJAX
rhino is right, the snippet lacks of a type for the sake of brevity.
Also, note that if
$php_varhas quotes, it will break your script. You shall use addslashes, htmlentities or a custom function.