Get ready for it, ’cause this php tutorial will show you how to display a message with PHP.

To get started, in the www folder, which we will call from now on root create a folder and name it lesson1 and then create inside a new file, called firstscript.php. Then paste the following code inside your file:

1
2
3
4
5
<?php

echo "Hello World!";

?>

Code output

Now, you can run the script at
http://127.0.0.1/lesson1/firstscript.php

Line by line explanation:

line 1: the openning tag for php. This tells the PHP parser on the server, that the following code is to be interpreted as PHP

line 3: starts with the keyword echo, which tells the PHP parser to display whatever it is next. And next is the text Hello World! between quotes, which tells the parser that he has to display the string Hello World!. In general, simple or double quotes enclose a char string. As all simple code lines, it is followed by ; – which tells the parser that the echo is over.

line 5: closes the php code section and tells the parser that the PHP code section is over, and it has no more parsing to do.

This being said, you created you’re first PHP script. Stand by for the nex PHP toturial.

Leave a Reply

Security Code:
Captcha reload captcha

Looking for something?
Archives
Blogroll