Showing posts with label Chapters. Show all posts
Showing posts with label Chapters. Show all posts

Monday, 5 December 2016

Chapter 7 (PHP) Date Command in php (How to display day and time in php)

HOW TO DISPLAY DATE AND TIME

We can show date and time in php .There is predefined date command in php with the help of that command we can see date and time.
With the help of program given below you will see how to use date command in php .

PROGRAM

<?php

echo("Date: " . date("D M d Y h:i:s") . "<br />");
?>

EXPLANATION

It is predefined command of php firstly we have to declare php tag and after that in echo we have to write like
echo("Date: " . date("D M d Y h:i:s") . "<br />");
as we know "Date: " display as same because written between" " after that we combine next with the help of . as we know dot is used for combining after that we use predefined date command function like date("D M d Y h:i:s") and after that with the help of dot we ca join it with break command.
NOW THE QUESTION IS WHAT IS THE MEANING OF ("D M d Y h:i:s")

The Meaning of D M d Y h:i:s is given below

* D - A textual representation of a day (three letters)
* M - A short textual representation of a month (three letters)
* d - The day of the month (from 01 to 31)
* Y - A four digit representation of a year
* h - 12-hour format of an hour (01 to 12)
* i - Minutes with leading zeros (00 to 59)

* s - Seconds, with leading zeros (00 to 59)

So it This way we can display date and time .

OUTPUT

THERE ARE MANY OTHER PREDEFINED CHRACTERS WHICH WE CAN USED IN DATE COMMAND 

These Chracters are  

    * d - The day of the month (from 01 to 31)
    * D - A textual representation of a day (three letters)
    * j - The day of the month without leading zeros (1 to 31)
    * l (lowercase 'L') - A full textual representation of a day
    * N - The ISO-8601 numeric representation of a day (1 for Monday through 7 for Sunday)
    * S - The English ordinal suffix for the day of the month (2 characters st, nd, rd or th. Works well with j)
    * w - A numeric representation of the day (0 for Sunday through 6 for Saturday)
    * z - The day of the year (from 0 through 365)
    * W - The ISO-8601 week number of year (weeks starting on Monday)
    * F - A full textual representation of a month (January through December)
    * m - A numeric representation of a month (from 01 to 12)
    * M - A short textual representation of a month (three letters)
    * n - A numeric representation of a month, without leading zeros (1 to 12)
    * t - The number of days in the given month
    * L - Whether it's a leap year (1 if it is a leap year, 0 otherwise)
    * o - The ISO-8601 year number
    * Y - A four digit representation of a year
    * y - A two digit representation of a year
    * a - Lowercase am or pm
    * A - Uppercase AM or PM
    * B - Swatch Internet time (000 to 999)
    * g - 12-hour format of an hour (1 to 12)
    * G - 24-hour format of an hour (0 to 23)
    * h - 12-hour format of an hour (01 to 12)
    * H - 24-hour format of an hour (00 to 23)
    * i - Minutes with leading zeros (00 to 59)
    * s - Seconds, with leading zeros (00 to 59)
    * e - The timezone identifier (Examples: UTC, Atlantic/Azores)
    * I (capital i) - Whether the date is in daylights savings time (1 if Daylight Savings Time, 0 otherwise)
    * O - Difference to Greenwich time (GMT) in hours (Example: +0100)
    * T - Timezone setting of the PHP machine (Examples: EST, MDT)
    * Z - Timezone offset in seconds. The offset west of UTC is negative, and the offset east of UTC is positive (-43200 to 43200)
    * c - The ISO-8601 date (e.g. 2004-02-12T15:19:21+00:00)
    * r - The RFC 2822 formatted date (e.g. Thu, 21 Dec 2000 16:01:07 +0200)
    * U - The seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

WE CAN ALSO GET DEFAULT TIME ZONE 


The method or program of default time zone get is given below.


PROGRAM

<?php
echo(date_default_timezone_get());

?>

EXPLANATION

We can also get default time zone there is a command (date_default_timezone_get());
with the help of this command we can get default time zone .It is predefined command or function
simply we have to declare php tag after that in echo we have write this command and after that close php tag and run the program.

OUTPUT



WE CAN ALSO SET MANUALLY DEFAULT TIME ZONE

The program of how to set manually default time zone is given below.

PROGRAM

<?php
echo(date_default_timezone_set("Europe/Paris"));
?> 

EXPLANATION


We can also set default time zone there is command(date_default_timezone_set("Europe/Paris"));
with the help of this command we can set default time zone .It is predefined commandor function.
simply we have to declare php tag after that in echo we have write this command and after that close php tag and run the program. In this program i write Europe/Paris.You can also write this according to your region .the output 1 shows that default time zone is set.

OUTPUT






If you have any query regarding this than please post a comment.




Sunday, 4 December 2016

Chapter 6(PHP) Looping Statements (For Loop,While Loop,Do while Loop )

For Loop In PHP

For Loop is the Loop which runs the code several time in loop
Suppose if we want to print number from 1 to 5 what a person do? he will first declare variable
$a=1;(assign value 1 to variable $a)
$b=2;
$c=3;
and in echo we display one by one $a,$b,$c like this .The number can be displayed with this method but we have to write so many coding lines but with the help of for loop we can write only one coding line and the program will run 5 time automatically  displayed the output .
To better understand this see program below

PROGRAM

<html>
<body>

<?php
for ($i=1; $i<=5; $i++)
  {
  echo "The number is " . $i . "<br />";
  }
?>

</body>
</html>

EXPLANATION

First of all we declare html tag ,body tag and php tag after that we use for loop like 
for ($i=1; $i<=5; $i++) 
in this $i=1; means we declare variable $i and assign value 1 to it.
$i<=5; this means run the program or loop while $i is less than or equal to 5
$i++ this means increment 
and in echo we display $i like
  echo "The number is " . $i . "<br />";
The number is written in" " means it display as it is and we can join the value of $i with the number is like . $i .
dot is used for joining and we use br tag to break the line and to show output like
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5


working 

$i=1 which is less than 5 so condition is true so it will inside coding of for loop and display Si whose value is 1 after that it get incremented from 1 to 2 now value of $i become 2 again it check condition of less than or equal to 5 .again 2 is also smaller than 5 so it goes in inside coding and now value of $i is 2 so in echo it display 2 .so in this way it repeat the code while $i is less than or equal to 5.
so it automatically display number from 1 to 5

OUTPUT


Below is the Example of how to make a table of  of any number

PROGRAM OF TABLE OF 13

<html>
<head>
</head>
<body>


<?php

$number = 13;

for ($x = 1; $x <= 10; $x++)
 {
    echo "$number x $x = ".($number * $x)."<br />";
}

?>

</body>
</html>

OUTPUT



WHILE LOOP

While Loop is also similar to for loop it also runs the block of code as many time as the while condition is true .how to use while use and how it works you better understand with the help of example given below

PROGRAM

<html>
<body>

<?php
$i=1;
while($i<=5)
  {
  echo "The number is " . $i . "<br />";
  $i++;
  }
?>

</body>
</html> 

EXPLANATION

First we declare html tag after that body tag and php tag and after php tag we initialize a user define variable  $i and assign a value 1 to it after that  we use while loop like while($i<=5) after that in echo we display or print $i and after that we increment $i and close all the tags .
first the value of $i is 1 which is less than or equal to 5 so condition is true so in echo it will display The number is 1 after that the value of $i is incremented from 1 to 2 and it again it goes in while loop and check the condition now value of $i is 2 it is also less than or equal to 5 so it again runs now it display or print in echo the number is 2 and again it compare and runs while $i is equal to 5.

OUTPUT



DO WHILE LOOP

Do While is little different from while loop. In do while looping statement first the do block will runs after that it will compare with the while loop and runs the code as many time as while loop is true.You will understand better how to use  do while loop with the help of program .The program of do while loop is given below .

PROGRAM

<html>
<body>

<?php
$i=1;
do
  {
  $i++;
  echo "The number is " . $i . "<br />";
  }
while ($i<=5);
?>

</body>
</html> 

EXPLANATION


First we declare html tag after that body tag and php tag and after php tag we initialize a user define variable  $i and assign a value 1 to it after that  we use do loop like
do
  {
  $i++;
  echo "The number is " . $i . "<br />";
  }
it do we increment $i means in do loop it increment the value of $i from 1 to 2 and in echo we print or display the incremented value of $i .after that we use while condition like while ($i<=5); after that we close html tag body tag and php tag.
Firstly the value of $i is 1 but as it enter in do it will incremented and become 2 and in echo we will display or print incremented value of $i which is 2 .
But the value of $i for comparing with while loop is 1 because we incremented value of $i in do and when the value of $i is 1 it will display incremented value of $i which is 2 and the loop for $i runs for 5 time and hence it will display 
The number is 2
The number is 3
The number is 4
The number is 5
The number is 6

The number is 2  is displayed when $i is 1
The number is 3  is displayed when $i is 2
The number is 4  is displayed when $i is 3
The number is 5  is displayed when $i is 4
The number is 6  is displayed when $i is 5

OUTPUT





If you any query regarding this than please post a comment below



Thursday, 1 December 2016

Chapter 5(PHP) Switch Statement And How to make Links From which we can go from one program to another

Switch Statement 

             Switch statement is used to run a particular block of the program .we write many cases in switch statement and the case which get matched with the value which we assign to user define variable will get executed.

PROGRAM

<html>
<body>

<?php
$x=2;
switch ($x)
{
case 1:
  echo "Number 1";
  break;
case 2:
  echo "Number 2";
  break;
case 3:
  echo "Number 3";
  break;
default:
  echo "No number between 1 and 3";
}
?>

</body>
</html> 

EXPLANATION
 Here we take a user define variable $x and assign value to it after that we use switch statement like
 switch ($x) after that we make different types of cases in switch statement like
case 1:
  echo "Number 1";
  break;
case 2:
  echo "Number 2";
  break;
case 3:
  echo "Number 3";
  break;
default:
  echo "No number between 1 and 3";

as we know we assign value 2 to the variable x and it matches with case 2 because 2 matches with 2 so case 2 will get executed.

break; is used to terminate the program and if we cant use break statement than other blocks below the matching case will also get executed.

OUTPUT



HOW TO MAKE LINKS FROM WHICH WE CAN GO FROM ONE PROGRAM TO ANOTHER
SAME METHOD IS USED IN WEBSITES

PROGRAM

<html>
<body>

<a href="p1.php">Home</a>
<a href="p4.php">Tutorials</a>



</body>
</html> 

EXPLANATION

This code is written in html first we have to declare <html> tag after that we have to declare body tag like <body> after that we have to write hypertext link which we can write as
<a href="p1.php">Home</a>
<a href="p4.php">Tutorials</a>

<a href="p1.php"> it means go to p1.php program you can also write any link which you want to go.
Home is the name of link which on clicking it will open p1.php program 
</a> closing hypertext link it is necessary to close.
and in last we close body tag and html tag like </body> </html> 
all the code should be written in body tag and after that body tag and html will be closed.

Wednesday, 30 November 2016

Chapter 4(PHP) If Else Statement,Else if Statement,Nested if Else Statement And Date Command

IF ELSE STATEMENT

If Else statement is a statement in which we can check the condition .If the condition is  true than
the if part of the program or code will run or execute and if the condition is not true than else part of the code or program is run.

PROGRAM

<html>
<body>

<?php
$d='1';
if ($d=="1")
  echo "Condition is true";

else

  echo "Condition is false";
?>

</body>

</html>

EXPLANATION
      
   In this program we take a user define variable $d and assign a value 1 to it.
  After that we use if statement and make condition if ($d=="1").It means we are comparing the             value of  $d  with 1 .Here the value assigned to $d is 1 so the condition become true and hence if         part of condition will execute and therefore   echo "Condition is true"; will execute .
  If the condition is not true than else part of condition will execute.

OUTPUT



ELSE IF STATEMENT

Else if statement is a statement in which we can check the condition .If the condition is  true than the if part of the program or code will run or execute and if the condition of if part is not true than it will compare condition  with else if part .If condition of else if part is true than it will execute that part of program .If the condition of else if part is also not true that it will execute else part of the program.

PROGRAM

<html>
<body>

<?php

$d='2';

if ($d=="1")
{
  echo "value is 1";
}
elseif ($d=="2")
{
  echo "value is 2";
}

else
{
  echo "Condition is false";
}
?>

</body>

</html>

EXPLANATION


     Here we take a user define variable $d and assign value 2 to it .After that we use if statement and make condition if ($d=="1") .After that we make else if condition like else if ($d=="2") .After that we write else statement .In this program the value of $d is 2 . The value of $d is compared with if and else if part of program .
And the part of program which is true will be executed and if both  if part and else if part of program are not true than else part of the program will be executed.
Here else if part of program is true because value of $d is 2 and in else if part we are comparing $d with 2 like ($d=="2") .And value of $d is 2 so 2=2 and hence else if part of program will be executed.

OUTPUT






NESTED IF ELSE STATEMENT

Nested if else statement means if statement inside the other if statement.
Nested if else statement is a statement in which we can check the condition .If the condition is  true than if will go inside the second if statement which we write if first if and compare it and if condition is true than it will execute second if statement and if condition id false than it will execute else part of second if statement.

PROGRAM

<html>
<body>

<?php
$d='1';
if ($d=="1")
{

$c='007';
if ($c=="007")
{
 echo "value is 007";
}
else
{
  echo "Condition is false";

}

}

else
{
  echo "Wrong Condition";
}
?>

</body>
</html>


EXPLANATION

In this program we take a user define variable $d and assign value 1 to it .
Firstly we make simple if else statement after that we write an another if else statement in the first if statement .If the if part of condition is true than if will go inside the first if statement and check the another if else statement which is written in first if statement and the part of program which is true will be executed and if the first if statement is not true than it will execute else part of program.
Here $d is equal to 1 and in our first if statement we compare value of $d with 1 .Hence the condition is true so it will go inside another if statement which is written in first .there we take a variable $c
and assign value 007 to it and compare it like if ($c=="007").If the condition is true than it will execute it and if condition is not true than it will execute else part of second if statement which is written inside first if statement.

OUTPUT


DATE COMMAND

          Date command is used to to check the current day.It is a predefined command which shows the current day .

PROGRAM

<html>
<body>

<?php

$d=date("D");
echo "Today is $d";
?>

</body>

</html>

EXPLANATION

It is a predefined command which we can use to show the current day .we can take a user define variable $d and assign date command to it like $d=date("D");
date("D") is predefined command and it should be written as it is.
And in echo we write $d which display the current day.

OUTPUT


Some Examples Of Using Date Command In IF ELSE And In  ELSE IF are given below


PROGRAM (Using date command in If Else Statement)

<html>
<body>

<?php
$d=date("D");
if ($d=="Fri")
  echo "Have a nice weekend!";
else
  echo "Have a nice day!";
?>

</body>
</html> 

OUTPUT



PROGRAM (Using date command in Else If Statement)

<html>
<body>

<?php
$d=date("D");
if ($d=="Fri")
  echo "Have a nice weekend!";
elseif ($d=="Sun")
  echo "Have a nice Sunday!";
else
  echo "Have a nice day!";
?>

</body>
</html> 

OUTPUT







Tuesday, 29 November 2016

Chapter 3(PHP) Types of Operators in PHP with Program and Explanation

There are Basically 4 types of opertaors in php language .The four types of the operator that are used in php are

  1. Logical AND Operator
  2. Logical OR Operator
  3. Logical NOT Operator
  4. Logical XOROperator 

     1 Logical AND Operator

        
         Sign of And Operator is &&

         Logical AND Operator will return the result true if all the conditions are true  .

EXAMPLE

<?php

$auth = 1;
$status = 1;
$role = 4;


$result = (($auth == 1) && ($status == 1));
print "result is $result";

?>
We Can also use print in place of echo

EXPLANATION

Here we take three user define variables $auth,$status and $role. we can assign some values to these variables.
Now  we define the fouth variable $result in which we can use And operator like
(($auth == 1) && ($status == 1)); 
the sign == means comparing in this we are comparing that $auth is equal to 1 or not and $status is equal to 1 or not.But here both are equal so the both results are true and it will returns true .
As we know in operators
1 means true
0 means false
OUTPUT





  2 Logical OR Operator

    
     Sign of OR Operator is ||

     Logical OR Operator will return the result true if any condition is true  .

EXAMPLE

<?php

$auth = 1;
$status = 1;
$role = 4;


$result = (($auth == 1) || ($role <= 2));
print "result is $result";

?>

EXPLANATION

Here we take three user define variables $auth,$status and $role. we can assign some values to these variables.
Now  we define the fouth variable $result in which we can use Or operator like
(($auth == 1) || ($role <= 2)); 
the sign == means comparing in this we are comparing that $auth is equal to 1 or not and $role is less tan or equal to 2.But here first condition is true $auth=1 but $role is not less than or equal to 2 beacuse $auth is equal to 4.But in Or operator if any one condition is true than it will return result as true .

OUTPUT


 3 Logical NOT Operator

    
     Sign of NOT Operator is !

     Logical NOT Operator will return the result true if any condition is false  .

EXAMPLE

<?php

$status = 1;

$result = !($status == 1);
print "result is $result";

?>

EXPLANATION

Here we take  user define variables $status and assign a value to it.
Now  we define other variable $result in which we can use NOT operator like
$result = !($status == 1); 
the sign == means comparing in this we are comparing that $auth is equal to 1 or not .But here we place sign of NOT operator(!)  and it will become Not equal to one but at upper $status is equal to one.The condition is true so it will not return result as true it will not display anything on execution.

OUTPUT


  4 Logical XOR Operator

   

     Logical XOR Operator will return the result true if either of two conditions are true, or returns            false if both conditions are true

EXAMPLE

<?php

$auth = 1;
$status = 1;

$result = (($status == 1) xor ($auth==1));
print "result is $result";

?>

EXPLANATION

Here we take two user define variables $auth and $status . we can assign some values to these variables.
Now  we define the third variable $result in which we can use XOR operator like
 (($status == 1) xor ($auth==1))
the sign == means comparing in this we are comparing that $status is equal to one or not and $auth is also equal to one or not.But here both the conditions are true because $status=1 and Sauth=1 so it will not return result as true so it will not show anything on execution.

OUTPUT

**  INCREMENT AND DECREMENT Operator

Sign of increment (++)
Sign of decrement (--)

Increment operator is used to add one to the value that we assign to of user define variable.
Decrement operator is used to substract one from the value that we assign to of user define variable.

EXAMPLE(Increment)

<?php

$total = 10;
$total++;

echo $total;

?> 

EXPLANATION
     
        In this program we take a user define variable $total and assign a value 10 to it .here we have to increment it so we use increment opertaor like $total++; 
it means add one to the value of user define variable .The value of user define varibale is 10 and after increment it will become 11 and that we display in echo. 

OUTPUT


EXAMPLE(Decrement)

<?php

$total = 10;
$total--;

echo $total;

?> 

EXPLANATION
     
        In this program we take a user define variable $total and assign a value 10 to it .here we have to decrement it so we use decrement opertaor like $total--; 
it means substract one to the value of user define variable .The value of user define varibale is 10 and after decrement it will become 9 and that we display in echo. 

OUTPUT


If u have any query regarding this than post a comment. 


Chapter 2(PHP) Some Basic Concepts of PHP With Program And Explanation


Program 1


How To Assign a value to a user define variable and to display it on execution?


<html>
<head></head>
<body>

<?php
$name = 'Rajat';
$class = 'BTECH';
$serialNumber = 1;

echo " I am $name studying in  $class. My serial number is $serialNumber.";
?>

</body>
</html>

EXPLANATION

In this program $name,$class and $serialNumber are user define variable.
and we will assign values to thses variables like $name = 'Rajat'; it means Rajat is assign to $name means $name contain the name Rajat.
$class = 'BTECH'; it means BTECH is assign to $class means $class contain BTECH.

The text value that should be assigned to user define variable should be writted between'    ' comma and ends by   ;   and if we assign a numeric value to variable than we should not write the numreic value in ' ' comma it will be writen directly as $serialNumber = 1; 

Now as we know echo is used to display combine these variable with text that should be written in echo like.

echo " I am $name studying in  $class. My serial number is $serialNumber."; 

OUTPUT



Program 2


How To Combine two user define variable or more in one userdefine variable  and to display it on execution?

<?php 

$identity = 'James Bond'; 
$car = 'BMW'; 

$sentence = "$identity drives a $car"; 
echo $sentence; 

?> 

EXPLANATION

In this program there are two variable $identity and $car and we assign values to these two variable 
and then assign to the third variable  like $sentence = "$identity drives a $car";  
it mean $sentense contain $identity value and $car value and the sentence become James Bond drives a BMW.
and in echo we will display $sentence.

OUTPUT
                   


Program 3


How To Add two numbers and to display it on execution?


<?php 

$a = 100; 
$b = 20;
$c=$a+$b; 

echo $c; 

?> 

EXPLANATION

In this program we take two user define variable $a and $b and assign values to these two variables .
and we take  the third variable $c in which we can ass both other variable like $c=$a+$b; 
and in echo we will display the variable $c in which we can add both the other variables.

OUTPUT


In same way we can substract,multiply and divide two numbers .






Program 4


How To Combine two user define in echo and to display on execution?

<?php
$txt1="Hello World!";
$txt2="What a nice day!";
echo $txt1 . " " . $txt2;
?> 

EXPLANATION

In this program we take two variable $txt1 and $txt2 and assign values to it like 
$txt1="Hello World!";
$txt2="What a nice day!";

in $txt1 we will assign Hello World!
in $txt2 we will assign What a nice day!

and combine these two in echo like echo $txt1 . " " . $txt2;
. " " . this is used to combine two variables

OUTPUT




Program 5


How To Count string length and display it on execution?


<?php

echo strlen("rajatsharma");
?> 

EXPLANATION

strlen means string length
strlen is used to count the string length  we have to write strlen in echo like 
echo strlen("rajatsharma");
it will count that how many chracters are there .

OUTPUT


Program 6


How To find position of chracter in string and display it on execution?


<?php
echo strpos("raj","a");
?> 

EXPLANATION

strpos means stringpostion.

In this program it will show the position of chracter a in the name  raj.
as we know count is start from 0 it means position of r is at 0 and a is at 1.
we have to write strpos in echo like 
echo strpos("raj","a"); 
it means tell postion of chracter a in raj

OUTPUT





Monday, 28 November 2016

Chapter 1(PHP) What is php and how to write a simple program in php and how to execute it ?



PHP is HyperText Preprocessor language.It is a scripting language basically used for web development.With the help of php language we can make websites .
Php is basically server side scripting language which runs on a web server we can write a code in this language and than that code will be executed on web server.
php language is embedded into html .

In  simple language we can say that php is used for web development or for making websites.

How to write a simple program in php language❓❔❓

Before writing the example of php i want to tell you that first we have to know about html language before writing the code in php .but if you dont know about html dont worry see my blogs and you will learn .i will also put my blogs on html language in which you will learn html language.

To RUN a php PROGRAM we also need web server beacuse as i explain above we need a web server to execute php code so you will have to download wampserver (which is web server)and  install it.there are also other web servers like apache and many more but i use wampserver.
we can write the code of php in notepad and save it with extension .php for example 1.php

SO HERE THE SIMPLE AND BASIC EXAMPLE OF PHP PROGRAM
                                  
                                                     <html> 
                                                    <head>
                                                    </head> 
                                                     <body>
                                                    <?php 
                                           echo "THIS IS RAJAT"; 
                                                      ?>
                                                     </body> 
                                                    </html> 

  we can write the basic php program like this we have to write all the code in body tag <body>.
<?php   is starting method of php code.
Suppose we are going to wite a program in php code than we have to write <?php tag which shows that code should be written in php language and after writing the code we have to close this tag like
?>

In php we use echo .basically what is echo and why it is used ? 

echo is predefine function used to display the content the content of program which we want to display when the code is get executed  
we can write as echo "rajat";
the text we want to display can be written in "" and ends with ;

for example in c++ language we use cout to display.
 All the tags should be closed in proper order if we cant close all the tag than our program will not get executed it will show error .



NOW THE THING IS HOW TO EXECUTE THIS PROGRAM

IT is very simple to execute it first we have to download wampserver and after that we have to install it in c drive and also create a shortcut on desktop.
now we have to double click on wampserver shortcut that created on desktop than a dialog box will appear on screen which will ask you for permission that do you want this app to run you will have to excute or click on yes.
now you will see w sign near the battery icon which is of red color it will changes to green .

after that you will have to left click on that w and differnt options will display you will have to select local host from these option.
                                           
 when u click on local host it will open in browser and dispaly as
                                                   
now you will have to set path  or environment varible 
we have to go in c drive we will see a folder name wamp we have to open it
now we see many folders we have to open bin folder and copy the address of that 
after that you will have to go in start button and write environment variable or we can open it from control panel system properties
now go in advance and click on environment variable 
now click on new button given ablove and a dialog box will appear like this
now write variable name as path and copy the link of bin from c going in wamp folder and open bin 
copy that in variable value and apply it or save it.


now we have to again open c drive go in wamp folder and after that you will see many folders 
open the folder www and create a new folder with any name which you want to give to save our program code which we write in notepad 
you have to save all the programs in that folder which you created in www 
now you have to left click on the green wampserver sign which is near battery sign and open local host
you will see your folder in your projects as i see my folder rajat in your projects
now open that folder and click on the program that you will save in this and it will get executed and dispaly the output



IF you  have any query regarding this than please post a comment .