Home  >  Article  >  Backend Development  >  How to call php from html

How to call php from html

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-10-21 13:54:034795browse

How to call php from html

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.

Related recommendations: "php Getting Started Tutorial"

You cannot directly call php files in static pages, but you can use js calling method to call php files, you can also use ajax calls php file.

Give a simple example to illustrate: Use the following code in page a.html to pass the action=test parameter to b.php.

The 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";    
?>

The above is the detailed content of How to call php from html. 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
Previous article:phpmyadmin2054 errorNext article:phpmyadmin2054 error