It seems that the php file cannot be called directly in the static page, but the php file can be called using the js calling method.
Recommended: php server
If you use the following call in the page demo.html, you can pass the parameter of f=onestopweb to p.php.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <script type="text/javascript" src="p.php?f=onestopweb"></script> <!-- //可以跨域访问 <script type="text/javascript" src="http://www.onestopweb.cn/p.php?f=onestopweb"></script--> </body> </html>
There is such a piece of PHP code in p.php:
<?php $f = $_GET['f']; echo "document.write('".$f."');"; ?>
When the demo.html file is executed, the p.php file will be called, and the output of the p.php file will be used as JS statement is executed, and the content is the value of parameter f passed by JS, which is the value of the action received in the PHP file.
Rendering:
The above is the detailed content of How to call php files in html. For more information, please follow other related articles on the PHP Chinese website!