Apr
3
Posted by admin Filed Under PHP

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

echo ‘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
This is the opening tag for php, without it your scripts wont work.

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

echo ‘Hello, World!”;
echo is the most basic and useful command that comes to my mind, it will print what you tell it to 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!


Leave a Reply

You must be logged in to post a comment.

comment
post
rss
    Pages