Home > Backend Development > PHP Problem > How to call php files in html

How to call php files in html

Release: 2023-02-27 22:56:02
Original
15939 people have browsed it

How to call php files in html

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>
Copy after login

There is such a piece of PHP code in p.php:

<?php
$f = $_GET[&#39;f&#39;];    
echo "document.write(&#39;".$f."&#39;);";   
?>
Copy after login

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:

How to call php files in html

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!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template