I made a javascript variable and assign some value
<script>
var score = 25;
</script>
after that i need that value inside php for any reason, unable to understand how to do so.
I made a javascript variable and assign some value
<script>
var score = 25;
</script>
after that i need that value inside php for any reason, unable to understand how to do so.
As JavaScript is a client-side language and PHP is a server-side language you would need to physically push the variable to the PHP script, by either including the variable on the page load of the PHP script (script.php?var=test), which really has nothing to do with JavaScript, or by passing the variable to the PHP via an AJAX/AHAH call each time the variable is changed.
If you did want to go down the second path, you'd be looking at XMLHttpRequest, or my preference, jQuerys Ajax calls: http://docs.jquery.com/Ajax