The concept of mixing PHP and HTML means to combine both codes together without loosing their separate identity. Before getting started let's take a look at the following points.
Any code written between these two tags are considered as PHP code, so don't forget to add these two tags when you start PHP code in HTML section. For further explanation let's take a look in the following example.
Please write the following code in your text editor and save the file as example.php or what ever you like the name but extension should be php.
<html>
<head>
<title> Mixing PHP and HTML </title>
</head>
<body>
Hey! this is html code. <br>
<?php
echo "Yeh! but this is php code.";
?>
</body>
</html>
In above example
<?php and ?> are php starting and ending tags
echo is output command
Semicolon ";" at the end of echo command is called command terminator, without this terminator php unable to make decision where the current command is terminated and the new is started.
- PHP is Server Side Code because it is executed or resolved on the server side, not in you browser.
- HTML is Client Side Code because it is executed in your browser.
Any code written between these two tags are considered as PHP code, so don't forget to add these two tags when you start PHP code in HTML section. For further explanation let's take a look in the following example.
Please write the following code in your text editor and save the file as example.php or what ever you like the name but extension should be php.
<html>
<head>
<title> Mixing PHP and HTML </title>
</head>
<body>
Hey! this is html code. <br>
<?php
echo "Yeh! but this is php code.";
?>
</body>
</html>
In above example
<?php and ?> are php starting and ending tags
echo is output command
Semicolon ";" at the end of echo command is called command terminator, without this terminator php unable to make decision where the current command is terminated and the new is started.
No comments:
Post a Comment