First Program


 

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"

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

<html>
<body>

<?php
print (“Hello World”);
?>

</body>
</html>

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>
5.
6. <body>
7.
8. <font color= “blue”>My PHP code makes this page say:</font>
9.
10. <p>
11.
12.<?php
13.
14. echo (“This is Rose India”);
15.
16. ?>
17. </p>
18.
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:

http://Deepak/sample/roseindia.php

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.

Ads