Embedding PHP code in regular HTML -
Lets 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 > |
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 -
1 2 3 4 5 6 7 8 9 10 | < 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