"."/> ".">

Home  >  Article  >  Backend Development  >  Can I use php in js?

Can I use php in js?

藏色散人
藏色散人Original
2022-10-18 09:55:493065browse

PHP can be used in js. The usage method is: 1. Open the corresponding js file; 2. Use the "b4ee84f03fa490f57d70d4618686bf9f2cacc6d41bbb37262a98f745aa00fbf0" method Just embed the php code in javascript.

Can I use php in js?

The operating environment of this tutorial: windows7 system, PHP8.1 version, DELL G3 computer

Can I use php in js?

1. Embed php code in javascript

If javascript is included through a js file, you can also write php code directly in the js file, but the extension of the js file must be Change to php, such as

<script herf="js/demo js php"></script>

2. Default values ​​of javascript function parameters In C language, you can set the default parameters like this

void foo(int a int b = bool c = false);

, but javascript cannot do this newGame: function(a b = )

IE and Chrome will report an error and ff will directly ignore it. We can use the arguments read-only variable array to achieve

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of Can I use php in js?. 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