PDA

View Full Version : Best Way of Passing PHP Variables to JS?



Tree
November 12th, 2005, 17:53
I need to pass PHP variables to a JavaScript script. Currently, I am using this code:


var foo = <?php echo $price['foo'] ?>;

Is that the best way to do it? I don't know as much about JS as I do about PHP.

XRated
November 12th, 2005, 21:38
I don't know any js , but the php bit seem's 100% reasonable to me ;)