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();
(2) test.php file
2. Use a tag to trigger php function
(1) HTML code
触发php函数
(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!