Home  >  Article  >  Backend Development  >  How to call php files in html

How to call php files in html

尚
Original
2019-10-29 15:56:0215887browse

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>

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

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

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!

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:php query if user existsNext article:php query if user exists