View Single Post
  #1 (permalink)  
Old 06-10-2007, 07:18 AM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 616
iTrader: (0)
Lee is just really niceLee is just really niceLee is just really niceLee is just really nice
Hello, world! Tutorial.

Like every other language there has to be a "Hello, World!" tutorial, so here it is.

You will need to have a text editor such as notepad or something along those lines, you will also need to have PHP on your host or computer, i recommend you get a host if your new to things such as this, it will save you a lot of time, i have my own hosting but i have used 9999mb.com which was good for this sort of thing so if you make an account there you can host your script.

Ok first off i will show you the code and tell you how to save it then i will explain each line.

Open your text editor and type:
PHP Code:
<?php

Print 'Hello, World!';

?>
When you have typed everything click on file -> save as and then save your file as hello.php ... Go to it in your browser and see the output, you have now wrote your first script!

What it means:

PHP Code:
<?php
This is the opening tag for php, without it your scripts wont work.

PHP Code:
?> 
This is the closing tag for php, again without it your scripts wont work.

PHP Code:
Print 'Hello, World!"; 
Print is the command which will basically do as it says, it will print it onto the page, inside the quote ' the text has to go, if you are printing variables then you have to use the double quotes " but we shall look at them at a later time, at the end of this line there is a semi-colon ; this tells php its the end of the command, if you dont include this it will think the script after that point is all ment to work but it wont you will end up with an error saying that a charachter is expected.

I hope i have explained this enough and that you understand it, try putting in your own message and see what happens!

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote