Home   |   About   |   Terms   |   Contact    
Read & Learn
 

How to use PHP inside HTML?

PHP

☯ All PHP Articles     ☯ All Articles


A new product.






Popular Google Pages:




This article is regarding
How to use PHP inside HTML?
What is php?
Start Tag and End Tag of PHP

Last updated on: .



◕ What is PHP?

PHP is a programming language. It is used mainly for building websites. Instead of running on a desktop computer for one person, PHP runs on a web server and is accessed by lots of people using web browsers on their own computers.



◕ Start tag and End tag of PHP.

<?php
This is the Start Tag of the PHP program.

?>
This is the End Tag of the PHP program.
Examples are given bellow.

- The PHP source code inside each set of <?php and ?> Tags are processed by the PHP engine.
- The PHP engine ignores anything outside of those tags.
- There is not interference of PHP on the texts which are before the Start Tag and after the End Tag.
Examples are given bellow.

Please note:
Some older PHP programs use <? as a Start Tag instead of <?php.
This <? is called the Short Open Tag.
But it is better to use the <?php as the Start Tag.



◕ How to use PHP inside HTML?

Example is given bellow:

<html>
<head>
<title>PHP inside HTML</title>
</head>
<body>
<?php
print "Here PHP is inside HTML!" ;
?>

</body>
</html>




◕ We can also put out PHP code before our HTML codes like:

<?php
// Our PHP codes before HTML.
?>

<html>
<head>
<title>PHP codes before HTML</title>
</head>
<body>
Our HTML Codes
</body>
</html>




◕ A PHP program can have multiple Start Tag and End Tag set inside the HTML code.
The example is given bellow.

<html>
<head>
<title>Multiple Start Tag & End Tag of PHP</title>
</head>
<body>
Apple
<?php
print "Apple is Red!" ;
?>

Orange
<?php
print "Orange is Yellow!" ;
?>

Mango
<?php
print "Mango is Green!" ;
?>

</body>
</html>



Related articles:
What is PHP?
How Website communicates with Server?
How PHP Works?
How to use PHP inside HTML?





Popular Google Pages:





Top of the page

Amazon & Flipkart Special Products

   


Top of the page