Home  >  Article  >  Backend Development  >  How to correctly output JS statements in PHP

How to correctly output JS statements in PHP

autoload
autoloadOriginal
2021-03-26 16:47:543440browse

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!

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