This PHP program is a simple
example of how PHP script tags
can be used within an HTML file
to dynamically generate content.
The program outputs a title, a
heading, some paragraphs, and
two lines of text that display the
current date and time.
• The opening ‘html’ tag indicates the
beginning of an HTML document.
• The ‘head’ section contains metadata about
the web page, such as the title (which
appears in the browser’s title bar), and any
stylesheets, scripts, or other resources that
the page needs to load.
• The ‘title’ element is used to specify the title
of the web page. In this case, it’s “0301 Using
PHP Script Tags”.
• The ‘style’ element is used to define CSS
styles that apply to elements in the HTML
document. The CSS code inside the ‘style’
element sets the font family to Arial,
Helvetica, sans-serif, and the font size to 16
pixels. This means that any text on the web
page will use this font family and size by
default.
• The ‘body’ element contains the visible content of the
web page, such as text, images, and other media.
• The ‘h1’ element is used to display the main heading of
the page, which in this case is "0301 Using PHP Script
Tags".
• The ‘p’ element is used to display a paragraph of text. In
this case, it asks the question "What are script tags and
why do we need them to run PHP?".
• The PHP code block starts with the ‘<?php’ tag, which
indicates that the code inside the tags should be
interpreted as PHP code by the server before being sent
to the browser.
• The $today variable is assigned the value of the current
date and time using the date function, which returns a
string in the format 'Y-m-d h:g:s', representing year,
month, day, hour, minute, and second.
• • The print statement outputs a string with the current
date and time, embedded inside HTML tags to format it
as bold text within a paragraph element (<p><b>Today is
$today </b></p>).
• The second PHP code block again uses the print
statement to output a similar string as the first block, but
with the word "STILL" added to indicate that the variable
$today still contains the same value as before.
• The closing body and html tags indicate the end of the
HTML document.
Overall, this program demonstrates how to use PHP code
to dynamically generate content on a web page. The PHP
code retrieves the current date and time, and then inserts
it into the HTML output using the print statement. The
resulting web page will display the current date and time
twice, along with some explanatory text.