以下文章提供了在 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中文網其他相關文章!