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

WBOY
Release: 2016-07-13 10:21:06
Original
1069 people have browsed it

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

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

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;>;
Copy after login

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

<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>

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...
Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template