Embedding PHP in HTML

Embedding PHP in HTML is so easy.

<html>
	<head>
	<title>PHP in HTML</title>
	</head>
	<body>
		
		<?php
			echo "Hello World";
		?>
		
		<p>Hi Universe!</p>
		
		<ul>
			<?php
				for($i=10; $i>0; $i--) {
			?>
				<li>
					This is number 
					<?php
						echo $i;
					?>
				</li>
			<?php
				}
			?>
		</ul>
	</body>
</html>

The following codes are the PHP codes that were embedded in our above HTML source code.

<?php
	echo "Hello World";
?>
...
...
<?php
	for($i=10; $i>0; $i--) {
?>
...
...
<?php
	echo $i;
?>
...
...
<?php
	}
?>

Embedding the PHP Code inside your HTML is a good programming style. It will help you develop web site much more faster and easier.

In our future discussion will have more advance of embedding techniques. Hope that helps and Thank you.

This entry was posted in PHP Beginners Course, PHP Tutorial. Bookmark the permalink.

3 Responses to Embedding PHP in HTML

  1. An impressive share, I simply given this onto a colleague who was doing somewhat evaluation on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I really feel strongly about it and love studying extra on this topic. If attainable, as you develop into experience, would you thoughts updating your blog with extra details? It’s highly helpful for me. Big thumb up for this blog submit!

  2. you’ve gotten an ideal blog here! would you like to make some invite posts on my blog?

  3. This page seems to recieve a good ammount of visitors. How do you get traffic to it? It offers a nice unique spin on things. I guess having something real or substantial to talk about is the most important thing.

Leave a Reply

Your email address will not be published. Required fields are marked *


*