Home > Backend Development > PHP Problem > Can I use php in js?

Can I use php in js?

藏色散人
Release: 2023-03-17 06:02:01
Original
3142 people have browsed it

PHP can be used in js. The usage method is: 1. Open the corresponding js file; 2. Use the "<script herf="js/demo js php"></script>" 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>
Copy after login

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);
Copy after login

, 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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template