I have this working JS code in my encode.html
file :
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script type="text/javascript">
var value; //this is the Value variable I want to access in PHP.
value = 'some value here'; //value variable gets updated.
</script>
</body>
</html>
And this working PHP code in sample.php
file :
<?php
$jsValue = 'value variable from javascript should go here';
//I want to access the value variable (from javascript) in the above PHP variable.
echo $jsValue; //print the value
?>
And I want to merge both files, to one. And access the variable value
from JavaScript and echo it in PHP, and use it in some functions later on. So, two things :
- How should I correctly format the code (so I could see it all in one file)?
- After merging the PHP & JS code, how should I access the
value
variable from JS in PHP, so I could assign it to a local PHP variable and use it later on?
I hope you understand my problem. Any help would be appreciated!