Wednesday, February 10, 2010

Displaying the words "Hello World!"

Hello Everyone,

To begin open the text editor you have chosen to use. After you have opened it, start a new page and save it as helloworld.php inside the directory for the server you as using.

Now we will type the code into the text editor for this page.

I will firstly show the code you will put in, then explain how it works.

<?php

echo "Hello World!";

?>

Now to explain the code.
The opening PHP Tag is shown first. The opening PHP Tag is used to tell the browser that the following code is PHP.
The next line contains the word echo, which displays text on the browser, in this instance it displays the text shown between the " ". At the end of that line there is a semicolon. A semicolon is used to denote the end of a line of code.
Lastly the last line is the closing PHP Tag, which is used to tell the browser where the end of the PHP code is.

Now you open the file stored on the server, via a web browser. When using XAMPP it would be http://localhost/Location-Of-File

Hello world! should now be displayed on the browser.

No comments:

Post a Comment