g Text Version
Beauty & Self
Books & Music
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
News & Politics
Religion & Spirituality
Travel & Culture
TV & Movies

Bored? Games!
Take a Quiz
Rate My Photo

Folklore and Mythology
Women's Fashion
Holiday/Seasonal Cooking
Hiking & Backpacking
New Age
Weight Loss

All times in EST

Full Schedule
g PHP Site

BellaOnline's PHP Editor


Say Hello World With PHP

Guest Author - Diane Cipollo

If you have read the first two tutorials in this series you should have everything installed on your computer that you will need to write and test your PHP programs. So let's get started. First open the Sokkit Control Panel and verify that the Sokkit web server is running. The button in the Web Server Controls section should be green. We will not be using MySQL. So you can leave that set to Stopped. Now open your text editor and type these three lines of code.

echo "Hello World";

Now let's break down the code and see how it works.

This is the opening PHP tag. It tells the server that the following lines of code are to be read as PHP and not as HTML.

echo "Hello World";
The echo statement (or command) tells the server to send everything that is between the quotation marks to the web browser and display it on the screen. In this example it will display or print Hello World to the screen. Notice that a PHP statement ends with a semicolon. The semicolon is an instruction terminator. It ends the command.

This is the closing PHP tag. It ends the PHP code.

That's all you have to do to print "Hello World" in the web browser. Are you asking yourself why you would even bother to write this script when you can do the same thing with basic HTML? Well, you probably wouldn't. This is an oversimplified example of a PHP script. In reality you would be using PHP to control what is printed to the webpage. For example: Is it Saturday? If yes, then print "What are you doing at work on a Saturday?". If it is not Saturday, then print "Get to Work".

Now you are ready to save your new script as a PHP program file. Click File and Save As and name your new script HelloWorld.php3. The php3 extension will tell the server to process this file as a PHP script and not as an HTML webpage. When you save your file you need to save it in the following location.


Are you in the right folder? If you see an HTML file called sokkitdefault.html, then you are in the right place.

Now we will test the script. Open the Sokkit Control Panel again and RIGHT click on the View Site button. Choose "Open in New Window" from the pop-up list. This will cause the sokkitdefault.html webpage to be displayed in the new window. You should see a message saying "This site is powered by Sokkit 3.4". Now go to the url address line in the web browser. It should say http://localhost/. To test your script all you need to do is to add HelloWorld.php3 at the end of this and click Enter. That will start your script and you will see a white page with the words "Hello World."


Congratulations! You have just written your first PHP program.

This site needs an editor - click to learn more!

Add Say+Hello+World+With+PHP to Twitter Add Say+Hello+World+With+PHP to Facebook Add Say+Hello+World+With+PHP to MySpace Add Say+Hello+World+With+PHP to Del.icio.us Digg Say+Hello+World+With+PHP Add Say+Hello+World+With+PHP to Yahoo My Web Add Say+Hello+World+With+PHP to Google Bookmarks Add Say+Hello+World+With+PHP to Stumbleupon Add Say+Hello+World+With+PHP to Reddit

RSS | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map

For FREE email updates, subscribe to the PHP Newsletter

Past Issues

Printer Friendly
tell friend
Tell a Friend
Email Editor

Content copyright © 2015 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.


g features
Archives | Site Map


Past Issues

Less than Monthly

BellaOnline on Facebook

| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2015 Minerva WebWorks LLC. All rights reserved.

BellaOnline Editor