PHP in HTML


Embedding into HTML .User Input, safe Handing user Input


PHP is an HTML-embedded server-side scripting language.The php language is to allow web
developers to write dynamically generated pages quickly.


PHP in HTML


When building a complex page, at some point you will be faced with the need to
combine PHP and HTML to achieve your needed results. At first point, this can seem
complicated, since PHP and HTML are two separate languages, but this is not the case. PHP
is designed to interact with HTML and PHP scripts can be included in an HTML page without
a problem.

In an HTML page, PHP code is enclosed within special PHP tags. When a visitor opens the
page, the server processes the PHP code and then sends the output (not the PHP code
itself) to the visitor's browser. Actually it is quite simple to integrate HTML and PHP. A PHP
script can be treated as an HTML page, with bits of PHP inserted here and there. Anything in
a PHP script that is not contained within <?php ?> tags is ignored by the PHP compiler and
passed directly to the web browser. If you look at the example below you can see what a
full PHP script might look like:

Prog1:

<html><head></head>
<body class="page_bg">
Hello, today is <?php echo date('l, F jS, Y'); ?>.</body></html>

Output:
Hello, today is Sunday, February 4th, 2018.
l-day, F-month, jS-date, Y-year
Prog2:

<html><head></head><body><ul>
<?php for($i=1;$i<=5;$i++){ ?>
<li>Menu Item <?php echo $i; ?></li>
<?php } ?>
</ul> </body></html>

Output:

• Menu Item 1

• Menu Item 2
• Menu Item 3
• Menu Item 4
• Menu Item 5

Custom Search

%d bloggers like this: