Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Monday, 22 December 2014

Post method in PHP

Structure of the Problem Requirements 

In this problem we will learn how to implement Post method in PHP. In post method parameters are not saved in browser history. Get method's request can't be bookmarked. Post method is used when sending passwords or sensitive data. One thing about post method that we can send limited data and the maximum size is 8 MB. Here is the source code of this problem which help you in better understanding.

Source code 

<?php
if(isset($_POST['name']) &&isset($_POST['pd']) && isset($_POST['age']) && isset($_POST['sex'])) {
$name = $_POST['name'];
$pd = $_POST['pd'];
$age = $_POST['age'];
$sex = $_POST['sex'];
}
?>
<html>
<title> GET METHOD IN PHP </title>
<body>
<form action="index.php" method="POST">
Name: <br> <input type="text" name="name" ><br>
Password: <br> <input type="password" name="pd" ><br>
Age: <br> <input type="number" name="age" ><br>
Sex: <br> <input type="text" name="sex" ><br>
<br> <input type="Submit" name="Submit" ><br>
</form>
</body>
</html>

Output of the Program

Post Method in PHP
Post Method in PHP

GET Method in PHP

Structure of the Problem Requirements 

In this problem we will learn how to implement get method in PHP. In get method parameters remain in browser history because they are part of the URL. Get Methods 's request can be bookmark. Get method should be used to retrieve data. Get method should not be used when sending passwords or other sensitive data. Here is the complete source code of this problem which help you in better understanding. 

Source Code 

<?php
if(isset($_GET['name']) &&isset($_GET['pd']) && isset($_GET['age']) && isset($_GET['sex'])) {
$name = $_GET['name'];
$pd = $_GET['pd'];
$age = $_GET['age'];
$sex = $_GET['sex'];
}
?>
<html>
<title> GET METHOD IN PHP </title>
<body>
<form action="index.php" method="GET">
Name: <br> <input type="text" name="name" ><br>
Password: <br> <input type="password" name="pd" ><br>
Age: <br> <input type="number" name="age" ><br>
Sex: <br> <input type="text" name="sex" ><br>
<br> <input type="Submit" name="Submit" ><br>
</form>
</body>
</html>

Output of the Program

Get Method in PHP
Get Method in PHP

Monday, 1 December 2014

For Loop in Php

Structure of the Problem Requirements 

In this problem we will discuss about for loop in Php. Loops are used to repeat the same pattern as per user requirements . But in our case we just initialize a number from 0 and tend it to 40. we have implement four for loops and in every for loops ten numbers are increases. Here is the source code of this example which help you in better understanding .


SOURCE CODE


<html>
<head>
<title>For Loops Php </title>
</head>
<body>
<?php
echo "<br />";
echo " For Loop _ 1 : ";
echo "<br />";
echo "<br />";
for ($Numbers=0; $Numbers <= 10; $Numbers++) {
echo $Numbers . ", ";
}
echo "<br />";
echo "<br />";
echo " For Loop _ 2 : ";
echo "<br />";
echo "<br />";
for ($Numbers=10; $Numbers <= 20; $Numbers++) {
echo $Numbers . ", ";
}
echo "<br />";
echo "<br />";
echo " For Loop _ 3 : ";
echo "<br />";
echo "<br />";
for ($Numbers=20; $Numbers <= 30; $Numbers++) {
echo $Numbers . ", ";
}
   echo "<br />";
echo "<br />";
echo " For Loop _ 4 : ";
echo "<br />";
echo "<br />";
for ($Numbers=30; $Numbers <= 40; $Numbers++) {
echo $Numbers . ", ";
}
?>
</body>
</html>

OUTPUT OF THE PROGRAM

For loop
For loop in php


Pointers in Php

Structure of the Problem Requirements 

Pointers are used to find the Memory address of the variables in Php.Pointers are also variables which hold the memory address instead of values. In Programming and complex Data Structures Pointers are used to Pass Value by Reference.Hope you will get a clear concept about Pointers in this Tutorial.

SOURCE CODE


<html>
<head>
<title>Pointers in Php</title>
</head>
<body>
<?php // Pointers and while loops revisited

$Numbers = array(1, 2, 3, 6, 12, 23);
?>
<?php
echo "1: " . current($Numbers) . "<br />";
next($Numbers);
echo "2: " . current($Numbers) . "<br />";
reset($Numbers);
echo "3: " . current($Numbers) . "<br />";
?>
<br />
<?php
while ($age = current($Numbers)) {
echo $age . ", ";
next($Numbers);
}
?>
</body>
</html>

OUTPUT OF THE PROGRAM

Pointers in Php
Pointers in Php


Switch Statement in Php

Structure of the Problem Requirements 

In this programme we will discuss about Switch statement in Php. The switch statement is used to avoid complex nested if else conditions. The structure of the switch statement is very simple we just pass a variable to the switch and test it in different cases. Each case end with break state and each new case start with new number. Here is the source code of this problem which help you in better understanding. 

SOURCE CODE

<html>
<head>
<title>Logical Expressions: Switch</title>
</head>
<body>
<?php 
/* switch
Useful when there are many possible actions based on the value of single variable
*/
$a = 2;
switch ($a) {
case 0: 
echo "a equals 0";
break;
case 1: 
echo "a equals 1";
break;
case 2: 
echo "a equals 2";
break;
default:
echo "a is not 0, 1, or 2";
break;
}
?>
</body>
</html>

OUTPUT OF THE PROGRAM



Switch Statement in Php
Switch Statement in Php

While Loop in Php

Structure of the Problem Requirements 

In this programme we will discuss about while lopp in php. How we can implement while loop in php. In our example we use while loop and display the number on screen and in second part of example we can use if else statement in while loop for understanding the While loop. Here is the source code of that Programmed that help you in better understanding.

SOURCE CODE


<html>
<head>
<title>Loops: while</title>
</head>
<body>
<?php /* while loops

while(expression)
statement;

{} around multi-line statements (like if-statements)
watch out for infinite loops
*/

// This loop outputs 0-10
$count = 0;
while ($count <= 10) {
echo $count . ", ";
$count++;
}
echo "<br />Count: {$count}";
?>
<br />
<?php
// Loops can be combined with if-statements
$count = 0;
while ($count <= 10) {
if ($count == 5) {
echo "FIVE, ";
} else {
echo $count . ", ";
}
$count++;
}
echo "<br />Count: {$count}";
?>

</body>
</html>

OUTPUT OF THE PROGRAM

While Loop in Php
While in Php

Friday, 28 November 2014

Array Functions in Php

Structure of the Problem Requirements 

In this programme we will implement some functions of Arrays in Php. In example we are take two Array and initialize them. And then some basic and important functions of String we can applied on them. Sorting , Reverse Sorting maximum and minimum number from array, these function will be applied in that example. Here is the source code of programme which help you in better understanding.

SOURCE CODE


<html>
<title> PHP Arrays Demo </title>
<body>
<?php 
echo "<br />";
$my_array_1 = array(21, 23, 15, 57, 29 );
echo "<br />";
?>
<?php
echo "Array 1 : ";
print_r($my_array_1);
echo "<br />";
echo "Total Length : ";
echo count($my_array_1);
echo "<br />";
echo "Maximum Digit : ";
echo max($my_array_1);
echo "<br />";
echo "Minimum Digit : ";
echo min($my_array_1);
echo "<br />";
echo "After Sort : ";
echo sort($my_array_1);
print_r($my_array_1);
echo "<br />";
echo "Reverse Sort : ";
echo rsort($my_array_1);
print_r($my_array_1);
?>
</body>
</html>

OUTPUT OF THE PROGRAM

Arrays in Php
Arrays Function

Arrays in PHP

Structure of the Problem Requirements 

In programme we will discuss about Arrays in Php Programming. Arrays is the collection of Data representation.  In our example we take two Arrays and Save some numbers in these arrays. And after that we manipulate Arrays and display the Arrays. Here is the source code of programme which help you in better understanding.

SOURCE CODE


<html>
<title> PHP Arrays Demo </title>
<body>
<?php 
echo "<br />";
$my_array_1 = array(1, 3, 5, 7, 9 );
$my_array_2 = array(2, 4, 6, 8, 10 );
echo "<br />";
?>
<?php
echo "Array 1 : ";
print_r($my_array_1);
echo "<br />";
print_r($my_array_2);
echo "<br />";
echo $my_array_1[0];
echo "<br />";
echo $my_array_2[0];
echo "<br />";
echo $my_array_1[1];
echo "<br />";
echo $my_array_2[1];
echo "<br />";
echo $my_array_1[3];
echo "<br />";
echo $my_array_2[3];
?>
</body>
</html>

OUTPUT OF THE PROGRAM

Arrays in PHP
Php Arrays 

 

Wednesday, 26 November 2014

Numbers increment and decrements in Php

Structure of the Problem Requirements 

In this programme we will tells about Number increment and decrements in php. As in our Last programme we tell you about numbers in php. but in this example we tell you about increment and decrements in numbers. Here is the source code of this Programmed from where you can understand better.      

SOURCE CODE


<html>
<title> PHP Number Demo </title>
<body>
<?php 
echo "<br />";
   echo "<br />";
$num_1 = 786;
$num_2 = 786;
echo "Number _ 1 : ";
echo $num_1;
echo "<br />";
echo "Number _ 2 : ";
echo $num_2;
echo "<br />";
?>
<?php
echo "<br />";
echo "<br />";
?>
<?php 
$num_3 = 0;
$num_3 = $num_1 + $num_2;
echo "Sum  : ";
echo $num_3;
echo "<br />";
echo "<br />";
?>
<?php
echo "First Increment Number 1 :   : ";
$num_1++;
echo $num_1;
echo "<br />";
echo "First Increment Number 1 :   : ";
$num_1++;
echo $num_1;
echo "<br />";
echo "First Increment Number 1 :   : ";
$num_1++;
echo $num_1;
echo "<br />";
echo "<br />";
?>
<?php
echo "<br />";
echo "First Decrement Number 1 :   : ";
$num_1--;
echo $num_1;
echo "<br />";
echo "First Decrement Number 1 :   : ";
$num_1--;
echo $num_1;
echo "<br />";
echo "First Decrement Number 1 :   : ";
$num_1--;
echo $num_1;
?>
</body>

</html>

OUTPUT OF THE PROGRAM



Numbers in hp
Number in Php

Numbers in Php

Structure of the Problem Requirements 

In this programme we will tells about Number in Php. How we can declare and initialize number in php. In our example we just initialize two numbers. and then find the sum of both two numbers and display them in Screen. Here is the source code of this Programmed from where you can understand better.  

SOURCE CODE


<html>
<title> PHP Number Demo </title>
<body>
<?php 
echo "<br />";
   echo "<br />";
$num_1 = 786;
$num_2 = 786;
echo "Number _ 1 : ";
echo $num_1;
echo "<br />";
echo "Number _ 2 : ";
echo $num_2;
echo "<br />";
?>
<?php
echo "<br />";
echo "<br />";
?>
<?php 
$num_3 = 0;
$num_3 = $num_1 + $num_2;
echo "Sum  : ";
echo $num_3;
echo "<br />";
echo "<br />";
?>
<?php
echo "<br />";
echo "<br />";
?>
</body>

</html>

OUTPUT OF THE PROGRAM


Numbers
Numbers in php


Tuesday, 25 November 2014

String Functions in PHP

Structure of the Problem Requirements 

In this programme we will implement some functions of String in Php. In example we are take two String and initialize them. And then some basic and important functions of String we can applied on them. Upper Case latter and lower case latter and Concatenate the string, these function will be applied in that example. Here is the source code of programme which help you in better understanding.

SOURCE CODE

   

<html>
<title> PHP Strings Demo </title>
<body>
<?php
echo "Simple Strings";
?>
<?php
echo "<br />";
   echo "<br />";
$f_String = "AsAd NaEeM ";
$s_String = "AN_DEvEloPer ";
echo $f_String;
echo $s_String;
echo "<br />";
echo "<br />";
?>

<?php
echo "Concate Strings";
echo "<br />";
echo "<br />";
?>
<?php
$t_String = $f_String;
$t_String .= $s_String;
echo $t_String;
echo "<br />";
echo "<br />";
?>
<?php
echo "LowerCase Strings";
echo "<br />";
echo "<br />";
?>
<?php
echo strtolower($t_String);
echo "<br />";
echo "<br />";
?>
<?php
echo "UpperCase Strings";
echo "<br />";
echo "<br />";
?>
<?php
echo strtoupper($t_String);
echo "<br />";
echo "<br />";
?>
</body>

</html>

OUTPUT OF THE PROGRAM


Functions of String
Functions of String


Strings in PHP

Structure of the Problem Requirements 

In programme we will discuss about Strings in Php Programming. We have just declare and initialize a Variable name my_String and saved value in this Variable. and then manipulate it with different other hard Coded String as like " PAKISTAN".Here is the source code of programme which help you in better understanding.
 

SOURCE CODE




<html>
<title> PHP Strings Demo </title>
<body>
<?php
$my_String = "AN Developer ";
echo $my_String;
echo " <br />";
echo " <br />";
echo $my_String . "PAKITSAN";
echo " <br />";
echo " <br />";
echo $my_String . "INDIA";
echo " <br />";
echo " <br />";
echo $my_String . "USA";
echo " <br />";
echo " <br />";
?>
</body>

</html>

Strings

Strings in Php 


My First PHP Programme

Structure of the Problem Requirements 

In programme we will implemented our first php tutorial. This is very somple web page in which there is only one statement of Php is being used. Title is given in html code and only one statement is added and this statement written in Php coding style.Here is the source code of programme which help you in better understanding.

SOURCE CODE


<html>
<title> My PHP </title>
<body>
<?php echo "My First PHP Programme \n"; ?>
</body>

</html>

My First Php Programme
Php Web Page