Embedding PHP code in regular HTML -
Lets create a hello script named hello.php.
<html> <head> <title>PHP Test</title> </head> <body> <?php echo '<p>Hello World</p>'; ?> </body> </html>In above html code, we printed Hello world in php code. To write php code in html we should use <?php ?> tags. Integrating php and html is very easy thing.
We can write more complex php code in html. We need to just start php code with <?php tag and end with ?> tag.
More advanced example -
<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
Item No 1
Item No 2
Item No 3
Item No 4
Item No 5
* If you like this post please don’t forget to subscribe Techies Badi - programming blog for more useful stuff
EmoticonEmoticon