Home  >  Article  >  Backend Development  >  Can php run js code?

Can php run js code?

青灯夜游
青灯夜游Original
2019-10-14 15:44:306281browse

Can php run js code?

php can run js code. In PHP, HTML code and JavaScript code are treated as strings and then parsed in the browser.

How to run JavaScript code in PHP:

Example 1: Writing JavaScript code in PHP code

';
echo 'alert("php中文网");';
echo '';
?>

Output:

Can php run js code?

Example 2: Writing JavaScript code outside of PHP code (in the same PHP file)

 

Output:

Can php run js code?

Example 3: JavaScript function - DOM manipulation (in the same PHP file)

"; ?>

Output:

Can php run js code?

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of Can php run js code?. 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
Previous article:Is ecshop a php framework?Next article:Is ecshop a php framework?

Related articles

See more