How HTML calls PHP

小云云
Release: 2023-03-21 06:34:02
Original
13729 people have browsed it

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

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
Copy after login
	$action=$_GET[&#39;action&#39;];     
	echo "document.write(&#39;".$action."&#39;);n";    
?>
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!