Marc Fraser | Web Design and Development Blog A Web Design and Development Blog by Marc Fraser. Marc Fraser is a student, situated in Central Scotland.

10Oct/090

Outputting HTML using PHP [+ Semicolons]

(from Full Article)

Semicolons

Semicolons are used extensively in PHP. The semicolon generally (there are exceptions) signifies the end of a PHP statement and should not be forgotten, otherwise unsightly errors will occur. An example will be shown in the Outputting HTML code using PHP section.

Outputting HTML code using PHP

Outputting HTML code using PHP is extremely easy. It can be done using the PHP Print command or indeed PHP Echo. The difference between the two commands can be read on the PHP FAQts site.

Below is how to output “This is my first output PHP string” in HTML paragraph and bold tags. This example will also show how the semicolon is used (read prior section, Semicolons).

<html>

<head>

<title>My first PHP outputs</title>

</head>

<body>

<?php

print “<p><strong>This is my first output PHP string</strong></p>”;

// For consistency I will show the use of the echo command

echo “<p><strong>This is my first output PHP string</strong></p>”;

?>

</body>

</html>

If you run the above code, you will see that you get the output:

First PHP output
First PHP output.

The first line is of the print command and the second line is the output of the echo command. Please note that there is no difference between the two. Please also note the usage of quotation marks – these are used to tell the PHP code that we wish not to execute the contents contained within.

   

Bad Behavior has blocked 66 access attempts in the last 7 days.