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:
1 2 3 4 5 6 7 8 | <html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>' ; ?>
</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:
1 2 3 4 5 6 | <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>
|
Copy after login
Output result:
1 2 3 4 5 | 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.
http://www.bkjia.com/PHPjc/998807.htmlwww.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...