以下文章提供了在 HTML 中嵌入 PHP 的概述。 HTML是一种预定义的前端语言代码,而php是一种服务器端脚本语言;它也称为嵌入式服务器端语言。大多数 PHP 语法代码必须遵循 c、java 和 Perl 脚本语言。它通常与其他基于 Web 的动态脚本语言一起使用,而且性能方面,与其他脚本语言相比,它会更好,而它与 html 代码配对用于创建基于 Web 的应用程序,它是一种不可中断的功能类型,用于创建网站。
语法:
嵌入的PHP代码是标准的,是一个普通的html文档;我们已经在 html 页面上编写了 PHP 代码。
代码:
<html> <head> <title> </title> <script language="php"> -----some codes---- </script> </head> </html>
上面的代码是借助<script>将php代码嵌入html页面的基本语法。标签;它也是可移植代码的另一种样式。</script>
以下是示例:
代码:
<html> <title>First Application of PHP</title> <body> <h3>Welcome To My Domain</h3> <?php echo "Welcome User"; ?> </body> </html>
输出:
Code:
<html> <title>Sample Application</title> <body> <h3>Welcome To My Domain</h3> <?php echo "Welcome Users."; ?> <p>Welcome</p> <?php $examp = "Welcome Users"; echo " $examp."; ?> </body> </html>
Output:
Code:
<html> <title>Sample Application</title> <h3>Welcome To My Domain</h3> <body> <a href="first.php">Home</a> <?php include "first.php"; ?> <a href="second.php">contactus</a> <?php include "second.php" ?> </body> </html>
First.php:
<?php echo "Welcome" ?>
Second.php:
<?php echo "User" ?>
Output:
The above examples show about the PHP codes in html document. First two example, we write the basic html codes combined with the PHP tags; it will show the output as a single web page HTML, but a final example will use the include tag in the PHP tag; it will include the external PHP files like first and second. PHP files it is used to navigate the web pages from one page into another web page.
In every open-source application, the developers will have the facility to add the codes and remove the codes based on the requirements. It has a group community like PHP Community to verify the codes and update the changes because the team have large members to solve the user issues.
以上是在 HTML 中嵌入 PHP的详细内容。更多信息请关注PHP中文网其他相关文章!