assign javascript variable to php variable code example
Example 1: how to use javascript variable in php
<script>
var p1 = "success";
</script>
<?php
echo "<script>document.writeln(p1);</script>";
?>
Example 2: how to use php variable in javascript file
<?php
$bool = false;
$num = 3 + 4;
$str = "A string here";
?>