Home >Backend Development >PHP Tutorial >Several ways for php to pass parameters to js functions, several ways for phpjs functions_PHP tutorial

Several ways for php to pass parameters to js functions, several ways for phpjs functions_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:21:061110browse

Several methods of passing parameters to js functions in php, several methods of phpjs functions

<&#63;php 
echo "<script>test('$_POST[userid]');</script> ";
&#63;>

The $_POST[''] above can also be applied to $_SESSION[' '];

<&#63;php 
$para = "hello boby!"; 
echo $para; 
echo "<script> var para=\"$para\"; alert(para);</script>"; 
&#63;>;

How to pass PHP variables as parameters into the js method?

3f1c4e4b6b16bbbd69b2ee476dc4f83a
function show(str){
alert(st);
}

show("eb4bd62954e83d68558dfe15e6d196b2");// Output the value of the php variable into the parameters of the JS calling function;
2cacc6d41bbb37262a98f745aa00fbf0

The value of js function parameter is passed between js and php

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/861792.htmlTechArticle Several methods of passing parameters to js functions in php, several methods of phpjs functions php echo "scripttest('$_POST [userid]');/script "; The above $_POST[''] can also be applied to $_SESSION[' ']; php $para = "hello...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn