Home >Web Front-end >HTML Tutorial >HTML calls PHP

HTML calls PHP

小云云
小云云Original
2018-03-20 11:42:4620575browse

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 one on this page.

<script type="text/javascript" src="click.php?id=123"></script>

Then on the click.php page, just follow the PHP syntax to process and operate the database.

You cannot directly call php files in static pages, but you can use js calling method to call php files, and you can also use ajax to call php files.
Give a simple example to illustrate: Use the following code in page a.html to pass the action=test parameter to b.php.
Javascript code is as follows:

<script type="text/javascript" src="b.php?action=test"></script>


There is such a PHP code in b.php:

<?php
$action=$_GET[&#39;action&#39;];     
echo "document.write(&#39;".$action."&#39;);n";    
?>

Related recommendations:

How HTML calls PHP

Examples of how JS calls PHP and PHP calls JS

How static html calls php files

The above is the detailed content of HTML calls PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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