How to execute php code in html file
What we introduce here is to execute it through js, as for modification The configuration files on the server will not be discussed here. Here we just provide an idea. After all, it is said on the Internet that php functions cannot be executed in HTML, let alone using frameworks.
<script src="test.php"></script> <script>document.write(a);</script>
The above is the front-end processing part.
This is what is written in test.php:
<?php //$a作为php变量,上面可以写你的php逻辑,处理的结果定义为你想要调用的结果即可; //但是一般不建议用这样的方式去在html调用php变量,这里只是提供一个解决的思路而已. //用这个去解决实际问题是不合理的,当个兴趣了解一下就可以了。 echo "var a=".$a; ?>
The above is how the php code is executed in the html file. Have you learned it?
This article is reproduced from: https://blog.csdn.net/zhou120189162/article/details/82256449
Recommended tutorial: "php tutorial"
The above is the detailed content of How to execute php code in html file (detailed explanation). For more information, please follow other related articles on the PHP Chinese website!