How to run js files in php?
If you want to run php code, you must first install the php running environment. You can go to the php official website to download and install.
After the environment is set up, we can write PHP code. As shown in the picture, we create a new php file.
Open with notepad and enter the following code.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GBK" /> </head> <body> <?php echo "<script type='text/javascript'>alert(''我是嵌入php内的js代码');</script>"; ?> </body> </html>
In the code, we use the tag to embed the js code into the php file. Running this file will pop up a prompt message.
Next, we use the browser to run the php file to see if our embedded js code is successful.
Then, the browser will pop up a prompt message for us. Explanation, our embedded js code is successful!
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to run js files in php. For more information, please follow other related articles on the PHP Chinese website!