+ 1
Can a PHP variable be passed to Javascript?
Is it possible to use a variable from a PHP script in Javascript and vice versa. Can variables be passed between the two languages?
2 Answers
+ 4
Something like that :
<?php echo "let foo =" +$bar; ?>
And put this in between script tags. Php is evaluated before Javascript, so it works.
To pass data from js to php, use ajax!
0
On a side note, there are other way around this problem : you could use cookies, you could use get variable..



