Home > Article > Backend Development > How to correctly output JS statements in PHP
A computer program is a series of "instructions" that are "executed" by the computer. In programming languages, these programming instructions are called statements. A JavaScript program is a series of programming statements. JavaScript statements are composed of: values, operators, expressions, keywords, and comments
1. Method:
echo "";
2. Example:
function getState(){ var cs = ".$state."; return cs; } "; ?>
3. JS garbled problem occurs:
header("Content-type:text/html;charset:utf-8")
Keep PHP encoding
is consistent with the browser parsed page encoding
.
Recommended: "php video tutorial" "php tutorial"
The above is the detailed content of How to correctly output JS statements in PHP. For more information, please follow other related articles on the PHP Chinese website!