Assign values to PHP variables, input values to variables in JavaScript, and assign values to javascript variables.
Copy codeThe Code is as follows:
$ (Document). ready (function (){
<? Php $ f = "'name'"?>
Var t = <? Php echo $ f?>;
Alert (t)
})
Or
Copy codeThe Code is as follows:
$ (Document). ready (function (){
<? Php $ f = "name"?>
Var t = "<? Php echo $ f?> ";
Alert (t)
})
Or
Copy codeThe Code is as follows:
<Script language = "javascript">
Var t = <? Php echo '"sd"'?>;
Alert (t)
</Script>
The key is that both single quotation marks and quotation marks must be added on both sides of sd. Otherwise, the display will be displayed.
"Sd is not defined
[Interrupted at this error]
Var t = sd ;"
Sd is a variable without quotation marks. If this variable is not defined before, it is assigned to another variable. Of course, an error is returned.