HTML itself cannot handle dynamic requests. To accomplish this, JavaScript is generally used. When generating a static web page, you can generate a corresponding JavaScript file reference for the HTML page based on the database ID. For example, if the page is 123.html, then generate a
<script type="text/javascript" src="click.php?id=123"></script>
on this page, and then on the click.php page, just process and operate the database according to the syntax of PHP.
静态页面中是不能直接调用php文件,但是有可以使用js调用方式来调用php文件,还可以使用ajax 调用php文件。 举一个简单的例子来说明:在页面a.html中使用如下代码,可以将action=test的参数传递到b.php。 Javascript代码如下: <script type="text/javascript" src="b.php?action=test"></script> 在b.php中有这样一段PHP代码: <?php
$action=$_GET['action']; echo "document.write('".$action."');n"; ?>
Related recommendations:
Examples of methods for JS to call PHP and PHP to call JS
How to call php custom functions
How to call php files from static html
The above is the detailed content of How HTML calls PHP. For more information, please follow other related articles on the PHP Chinese website!