Can html trigger php functions?

angryTom
Release: 2023-02-28 18:20:01
Original
2798 people have browsed it

Can html trigger php functions?

Can html trigger php functions?

html cannot trigger php functions. HTML is a hypertext markup language, which is only used to build the page structure. It cannot trigger a certain function of php.

To trigger a certain function of PHP, we have the following implementation methods:

● Use JavaScript to send an ajax request and trigger a certain function of PHP.

● Use the a tag to refresh the page and bring some parameters to trigger a certain function of PHP.

The specific implementation method is as follows:

1. Use Ajax to trigger php functions

(1) JavaScript code

var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.responseText) } }; xmlhttp.open("GET", "test.php?func=sayHi", true); xmlhttp.send();
Copy after login

(2) test.php file

Copy after login

2. Use a tag to trigger php function

(1) HTML code

触发php函数
Copy after login

(2 ) test.php file is the same as above

Recommended: "PHP Tutorial"

The above is the detailed content of Can html trigger php functions?. 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
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!