Share on Google+Share on Google+

First Program

Now, lets move ahead for printing the first and most simple & common example of programming "Hello World"

Now, lets move ahead for printing the first and most simple & common example of programming “Hello World”.


print (“Hello World”);


Here, you see that the code is written containing HTML tags and works like a HTML file but the chunk written within the PHP syntax works as a PHP code.

For further clarification, lets see another example:

1. <html>
2.  <head>
3.  <title> Rose India Example Title </title>
4. </head>
6. <body>
8. <font color= “blue”>My PHP code makes this page say:</font>
10. <p>
14. echo (“This is Rose India”);
16. ?>
17. </p>
19. </body>
20. </html>

Here, the piece written under HTML tag works like HTML while the chunk written under PHP tag functions like PHP file.

After compiling, testing and running the programme, save the file with any name without giving any spaces, and with extension .php. If server is installed on your machine, save the file somewhere inside the server’s root folder (on Windows this is typically in the "wwwroot" directory inside the "inetpub" directory on your C: drive).

How to open the file?

To open the closed file, you will have to open the file URL on your web server which you have already installed. The URL finds the correct path and file on your web server. On windows, your computer name is your root URL. For instance, the name of my computer is ‘Deepak’, so I’ll have to type the name of my computer, the directory in which the PHP file is saved and the file name. See, it is like:


3.3 Error Messages

If you are opening the file from the exact route, the file will be opened, otherwise you will see an error like that…

Parse error:
Parse error in C:\intepub\wwwroot\Roseindia_article\roseindia.php
on line 10

This sort of error reflects that there is some error in my coding at line 10 of my file roseindia.php.

Now, lets move towards the variable used in PHP script.


Posted on: July 10, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.