0% found this document useful (0 votes)
5 views3 pages

PHP HTML Document Structure Explained

The document provides a breakdown of a PHP script that outputs an HTML document. It explains the PHP opening and closing tags, the use of the echo statement to output HTML, and details the structure of the HTML document including the DOCTYPE declaration, head section with meta tags, title, style section, body content, and the closing HTML tag. Each component is described with its purpose and functionality in the context of web development.

Uploaded by

Noriel Galoso
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

PHP HTML Document Structure Explained

The document provides a breakdown of a PHP script that outputs an HTML document. It explains the PHP opening and closing tags, the use of the echo statement to output HTML, and details the structure of the HTML document including the DOCTYPE declaration, head section with meta tags, title, style section, body content, and the closing HTML tag. Each component is described with its purpose and functionality in the context of web development.

Uploaded by

Noriel Galoso
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Code Breakdown

1. PHP Opening Tag:

php

RunCopy code
<?php
This indicates the start of a PHP script. The server will interpret the code within
these tags as PHP.

2. Echo Statement:

php3 lines

Click to expand

echo '<!DOCTYPE html>

...

...

The echo statement is used to output text. In this case, it outputs a complete
HTML document as a string. The HTML content is enclosed in single quotes.

3. HTML Document Structure:


 DOCTYPE Declaration:

html

RunCopy code
<!DOCTYPE html>
This declaration defines the document type and version of HTML being
used (HTML5 in this case).
 HTML Tag:

html

RunCopy code
<html lang="en">
This tag starts the HTML document and specifies the language as
English.
 Head Section:

html8 lines

Click to expand

<head>

<meta charset="UTF-8">
...

 Meta Tags:
 <meta charset="UTF-8">: Sets the character encoding to
UTF-8, which supports a wide range of characters.
 <meta name="viewport" content="width=device-width,
initial-scale=1.0">: Ensures the page is responsive and
scales correctly on different devices.
 Title Tag:

html

RunCopy code
<title>Hello World</title>
This sets the title of the web page, which appears in the browser
tab.
 Style Section:

html15 lines

Click to expand

<style>

body {

...

This section contains CSS styles:


 The body is styled to use Flexbox for layout, aligning items
to the left and centering them vertically. The height is set to
100% of the viewport height, and margins are removed. The
font is set to Arial or a sans-serif fallback.
 The h1 element (the main heading) is given a font size of
3em and padding of 10px. There is a commented-out line for
a border that is not currently active.

4. Body Section:

html3 lines

Click to expand

<body>

<h1>Hello, World!</h1>

...

This section contains the content of the web page. It includes an h1 heading that
displays "Hello, World!".
5. Closing HTML Tag:

html

RunCopy code
</html>';
This closes the HTML document.

6. PHP Closing Tag:

php

RunCopy code
?>
This indicates the end of the PHP script.

You might also like