PHP variable assignment, substituting for variables in JavaScript, assigning JavaScript
Copy the Code code as follows:
$ (document). Ready (function () {
<?php $f = "' Name '"?>
var t=<?php echo $f?>;
Alert (t)
})
Or
Copy the Code code as follows:
$ (document). Ready (function () {
<?php $f = "name"?>
var t= "<?php Echo $f?>";
Alert (t)
})
Or
Copy the Code code as follows:
The key is to add a single quote and quotation marks on both sides of the SD, otherwise it will be displayed
"SD is not defined
[Break at this error]
var t=sd; "
SD without quotation marks is a variable, not defined before the variable, you assign him to other variables, of course, will error
http://www.bkjia.com/PHPjc/1024131.html www.bkjia.com true http://www.bkjia.com/PHPjc/1024131.html techarticle PHP variables are assigned, and are assigned to variables in JavaScript, and the assigned JavaScript copy code code is as follows: $ (document). Ready (function () {PHP $f = "' Name '" Var t=php echo $f; Alert (t)}) or copy ...