Home > Backend Development > PHP Tutorial > How to embed PHP code in HTML, embed php_PHP tutorial

How to embed PHP code in HTML, embed php_PHP tutorial

WBOY
Release: 2016-07-13 09:53:59
Original
1242 people have browsed it

How to embed PHP code in HTML, embed php

For an experienced PHP web developer, this is a very easy thing. But this is a problem for those new to the PHP programming language. So here's how to embed PHP code in regular HTML code.

Embed PHP code in regular HTML

Create a hello script named hello.php:

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<&#63;php echo '<p>Hello World</p>'; &#63;>
</body>
</html>
Copy after login

In the above HTML code, Hello is printed in the PHP code. Writing PHP code in HTML requires the use of tags. Integrating PHP and HTML is very simple.

We can also write more complex PHP code in HTML by using tag.

More advanced code examples:

<html>
<head>PHP HTML Integration</head>
<body>
<ul> <&#63;php for($i=1;$i<=5;$i++){ &#63;> <li>Item No <&#63;php echo $i; &#63;></li> <&#63;php } &#63;> </ul>
</body>
</html>
Copy after login

Output result:

Item No 1
Item No 2
Item No 3
Item No 4
Item No 5
Copy after login

The above is the entire content of this article, I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/998807.htmlTechArticleHow to embed PHP code in HTML, embed php For an experienced PHP web developer, this is a Very easy thing. But for those who are new to the PHP programming language...
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