<?php echo "<script>test('$_POST[userid]');</script> "; ?>
The $_POST[''] above can also be applied to $_SESSION[' '];
<?php $para = "hello boby!"; echo $para; echo "<script> var para=\"$para\"; alert(para);</script>"; ?>;
<script><br>function show(str){<br> alert(st);<br>}<br> <br>show("<?php echo $value; ?>");// Output the value of the php variable into the parameters of the JS calling function; <br></script>
What you are doing is using JS variables in PHP, which is not feasible and impossible.
First of all, you must understand that the PHP script is compiled immediately, and the compilation is completed. Only PHP can execute HTML and JavaScript.
I think your requirement does not require JavaScript. You can use get/post to pass the value of your SID. If you want no refresh, you need to Use ajax asynchronously to achieve it.
Just a moment:
You can use php variables in js, but not vice versa