Home >Backend Development >PHP Tutorial >How to embed PHP code in HTML, embed php_PHP tutorial
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> <?php echo '<p>Hello World</p>'; ?> </body> </html>
In the above HTML code, Hello is printed in the PHP code. Writing PHP code in HTML requires the use of bb9bd6d87db7f8730c53cb084e6b4d2d tags. Integrating PHP and HTML is very simple.
We can also write more complex PHP code in HTML by using af689f0c12a0d6c13d531abc1bf17f55 tag.
More advanced code examples:
<html> <head>PHP HTML Integration</head> <body> <ul> <?php for($i=1;$i<=5;$i++){ ?> <li>Item No <?php echo $i; ?></li> <?php } ?> </ul> </body> </html>
Output result:
Item No 1 Item No 2 Item No 3 Item No 4 Item No 5
The above is the entire content of this article, I hope you all like it.