Skip to main content

Posts

PHP (Personal Home Page)

PHP is a general-purpose scripting language geared towards web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994 .  The PHP reference implementation is now produced by The PHP Group. PHP originally stood for Personal Home Page , but it now stands for the recursive initialism PHP: Hypertext Preprocessor . PHP code is usually processed on a web server by a PHP interpreter implemented as a module, a daemon or as a Common Gateway Interface (CGI) executable.  On a web server, the result of the interpreted and executed PHP code – which may be any type of data, such as generated HTML or binary image data – would form the whole or part of an HTTP response. Various web template systems, web content management systems, and web frameworks exist which can be employed to orchestrate or facilitate the generation of that response.  Additionally, PHP can be used for many programming tasks outside the web context, such as standalone graphical app...
Recent posts

Internal Exam

HTML CODE: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>PHP Operations</title> </head> <body> <form action="p1.php" method="post"> <label>Enter First String:</label> <input type="text" name="n1"><br> <label>Enter Second String:</label> <input type="text" name="n2"><br> <input type="submit" name="enter" value="Enter"> </form> </body> </html> PHP CODE: <?php $str1 = $_POST['n1']; $str2 = $_POST['n2']; function mod($str1 , $str2) { $mod = $str1 % $str2; echo "mod is ".$mod."<br>"; } mod($str1, $str2); function power($str1, $str2) { $power = $str1 ** $str2; echo "power is "...

//First Program in PHP

First Program in PHP  <?php //First Program in PHP echo "hellow php"; //"echo" use for print line .                   //what kind of to print, just write after 'echo' in ""(duble quote). ?> 👉 Execute 👈 //Output /* hellow php */                                                                                                        //ThE ProFessoR    

//Function:-Arthmatic Operation

Function:-Arthmatic Operation  <?php //Function Arthmatic Operation //Function Definition //Addition function add ($a ,$b)  //function name must start with letter or underscore. { $c = $a + $b; echo "the addtion is:".$c."<br>" ; } add (20, 40);    //Function Call:- You can many times call function. add (45, 45);  //you can add many argumentsas you want. //Subtraction function sub ($a, $b) { $c = $a - $b; echo "the subtraction is ".$c."<br>"; } sub (45, 25); //45, 25 this value store in 'a' and 'b', then execute operation "45 - 25 = 20". //Division function div ($a ,$b) { $c = $a / $b; echo "the division is:" .$c. "<br>"; } div (100, 4); //Multiplication function multi ($a ,$b) { $c = $a - $b; echo "the multipication is:" .$c. "<br>"; //"echo" use for print line. } multi (50, 20); //Modulus func...

//Switch Case (Integer)

Switch Case (Integer) <?php  //Switch Integer:- In Switch Integer we use Numbers(integers) $a = 30; / /variable def $b = 20; $c; $int = '1'; //which case you want to execute 'Enter' case value. switch ($int)  { case '1': //the case label must end with colon(:) { //Addition $c = $a + $b; echo "the addition of a+b is:".$c."<br>"; //"echo" use for print line. break ; //It's necessary to use break after each block. } case '2': //case label must be unique. { //Subtract $c = $a - $b; echo "the subtraction of a+b is:".$c."<br>"; //"<br>" use for linebreak. break ; //if you don't use it, then all cases executed. } case '3': { //Multiplication $c = $a * $b; echo "the mulitiplication of a+b is:".$c."<br>"; break ; } case '4': { //Division $c = $a / $b; echo "th...

//Switch Case (String)

 Switch Case (String) <?php  //Switch String:- In Switch String we use words and numbers in "duble quotes". $a = 30;  //Variable Def $b = 20; $c; $string = 'five'; //which case you want to execute 'Enter' case. value. switch ($string)  { case 'one': //the case label must be end with colon(:) { //Addition $c = $a + $b; echo "the addition of a+b is:".$c."<br>"; //"echo" use for print line. break ; //It's necessary to use break after each block. } case 'two': //case label must be unique. { //Subtract $c = $a - $b; echo "the subtraction of a-b is:".$c."<br>"; //"<br>" use for linebreak. break ; //if you don't use it, then all cases executed. } case 'three': { //Multiplication $c = $a * $b; echo "the mulitiplication of a*b is:".$c."<br>"; break ; } case 'f...

//Switch Case (Character)

Switch Case (Character)  <?php  //Switch Char:- In switch char we use character for ex. + ,-, *, /, %, @ $a = 30; / /Variable Def $b = 20; $c; $ch = '+'; //which case you want to execute 'Enter' case value. switch ($ch)  { case '+': //the case label must be end with colon(:) { //Addition $c = $a + $b; echo "the addition of a+b is:".$c."<br>"; //"echo" use for print line.   break ; //It's necessary to use break after each block. } case '-': //case label must be unique. { //Subtract $c = $a - $b; echo "the subtraction of a+b is:".$c."<br>"; //"<br>" use for linebreak. break ; //if you don't use it, then all cases executed. } case '*': { //Multiplication $c = $a * $b; echo "the mulitiplication of a+b is:".$c."<br>"; break ; } case '/': { //Division $c = $a ...

//For Loop

For Loop  <?php //forloop //print 10 to 20 $a; //'$' use for variables   for ($a=10; $a <= 20 ; $a++)  // (a=10 is initialization statement);(a<=20 is test condition statement);(a++ is increment statement)                          //Initialization:-the control-variable is done first, using assignment statement such as a=10 or count=0.                         //Test Condition:- If condition is 'True', the body of loop is ececuted. Otherwise the the loop is terminted.                        //Increment/Decrement:- here is 'Increment' then, the control variable is incremented and this value again tested.                       //this process continues till the value of the control variable fails to satisfy the test-co...

//Do-while

 Do-while  <?php // Dowhile  //print number 20 to 40  $a = 20; // $ use for variables     do // the body of the loop is excuted at least once time.   {   echo "the value of a is: $a <br>"; //"<br>" use for linebreak. //"echo" use for print line.       $a++;                             //(a=20 <= 40) the condition is True; therefore execute conditional code.   } while ($a <= 40)                     //the condition is true; then control jumps to back 'do', and the loop again ececutes unitl then condition is false. ?> 👉 Exexute 👈 //Output /*   the value of a is: 20 the value of a is: 21 the value of a is: 22 the value of a is: 23 the value of a is: 24 the value of a is: 25 the value of a is: 26 the value of a is: 27 the value of a is: 28 the value of a...

//While Loop

While Loop  <?php  //while loop // print number from 10 to 20 $a = 10; while ($a <= 20) //(a=10 <= 20) the condition is True; therefore excute conditional code.                //when condition is true then excute conditional code; otherwise loop body skipped. { //the body of loop echo "the value of a is: $a <br>";  // echo use for print line. $a++; // a++ for this condition 'a <= 20'. value increase upto 20. } ?> 👉 Execute 👈 //Output /* the value of a is: 10 the value of a is: 11 the value of a is: 12 the value of a is: 13 the value of a is: 14 the value of a is: 15 the value of a is: 16 the value of a is: 17 the value of a is: 18 the value of a is: 19 the value of a is: 20 */                                                 //ThE ProFessoR

//Break And Continue Statement

Break And Continue Statement  <?php //Break And Continue Statement $a = 10; // $ use for variables  while ($a <= 20)   { if ($a == 15) //(a==15)when... //block of code to be executed if the condition is True. {  { $a++; echo ("in if the statement a is:" .$a."<br>"); break; //Break :- when the loop iterates for first time, the value of i=10, the if statement result will be false, so the else condition is executed.   //loop iterates again now i=15; if condition result will be 'True' and loop breaks.      //you can also use 'Continue'      //Continue:-when the loop iterate for the first time the value of i=10, the if statement result will be false, so the else condition 2 is implemented.    //loop iterates again now i=15; if condition result will be 'True' and the code stop in between and strat new iterate unitl the end condition met. } echo ("the value of a is:".$a."<b...

//Relation Operator

Relation Operator  <?php  $a = 21;  // '$' use for variables $b = 10; //equal to if ($a == $b) / / (a=21 == b=10) is False; Therefore a is not equal to b.              //the two given values are equal to each other then result will be True, Otherwise it returns False. { echo "a is equal to b"."<br>"; }  else  { echo "a is not equal to b"."<br>"; //"echo" use for print line. } //grater than if ($a > $b) //(a=21 > b=10) is True; Therefore a is grater than b.             //the first value is grater than the second value then result will be True, Otherwise it returns False. { echo "a is greater than b"."<br>"; }  else { echo "a is not greater than b"."<br>"; //"<br>" use for linebreak. } //less than if ($a < $b) //(a=21 < b=10) is False; Therefore a is not less than b.             //the first value is less tha...

//Logical Operator

Logical Operator  <?php  //Logical Operator $a = 50; $b = 30; //Logical AND //we use also  Logical NOT if (!(($a > $b) && ($a != $b))) // !(a=50 > b=30) is False && (a=50 != b=30) is True; Therefore this statement is False.                                // when both statement are True then result will be True.                               // '!'not is True statement consider False and False statement consider to True. { echo "this statement is true <br>"; } else { echo "this is statement is false <br>"; } //Logical OR if (($a < $b) || ($a != $b)) / / (a=50 < b=30) is False || (a=50 != b=30) is True; therefore this statement is True.                         //if one(or both) statement is True then result will ...

//Birwise Operator

Birwise Operator  <?php  $a = 50; //110010 in binary.   $b = 30; //11110 in binary. $c = 0; $d = 0; // $ use for variables. $e = 0; $f = 0; $g = 0; $h = 0; //Bitwise AND $c = $a & $b; // 110010 & 11110 = 10010 i.e means is '18'. echo ("The value of AND is:- $c <br>"); //Bitwise OR $d = $a | $b; // 110010 | 11110 = 111110 i.e means is '62'. echo ("The value of OR is:- $d <br>");  // <br> use for linebreake //Bitwise Exclusive XOR $e = $a ^ $b; echo ("The value of Exclusive OR is:- $e <br>"); // echo use for print line. //Bitwise Complement $f = ~$a; // -(50+1)= i.e means is '-51'. echo ("The value of Complement is:- $f <br>");  // .$c. is used to indicate which value should be print. //Bitwise Shift Left $g = $a << 2; //50=110010 << 2 :- 11001000 i.e means is '200'. //Shift with 2 zero to left side. echo ("The value of Shift Left is:- $g <br>");...

//Assignment Operators

Assignment Operators  <?php  $a = 21;  $c = 10;  // $ use for variables  //Add AND $c += $a; //c = c + a; 10 + 21 = 31; echo ("the value of c is :".$c."<br>"); // <br> use for linebreake //Subtract AND $c -= $a; //c = c - a; 31 - 21 = 10; echo ("the value of c is :" .$c."<br>"); // .$c. is used to indicate which value should be print. //Multiply AND $c *= $a; //c = c * a; 10 * 21 = 210; echo ("the value of c is :" .$c."<br>"); // echo use for print line. //Divison AND $c /= $a; // c = c /a; 210/10 = 10; echo ("the value of c is :". $c."<br>"); //Mod AND $c %= $a; // c = c % a; 10 % 10 =10; echo ("the value of c is :" .$c."<br>");  ?> // Execute //Output /*  the value of c is :31 the value of c is :10 the value of c is :210 the value of c is :10 the value of c is :10  */                                       ...

//Arthmatic Operator

Arthmatic Operator <?php //Arthmatic Operator $a = 21; // $ use for variables    $b = 10; //Addition $ c = $ a + $ b; echo ("the value of c is :". $ c." <br> "); // echo use for print line. //Subtraction $ c = $ a - $ b; echo ("the value of c is :" . $ c." <br> "); // .$c. is used to indicate which value should be print. //Multiplication $ c = $ a * $ b; echo ("the value of c is :" . $ c." <br> "); // <br> use for linebreake //Division $ c = $ a / $ b; echo ("the value of c is :". $ c." <br> "); //Modulus $ c = $ a % $ b; echo ("the value of c is :" . $ c." <br> "); ?>   // Execute /* Output   the value of c is :31 the value of c is :11 the value of c is :210 the value of c is :2.1 the value of c is :1     */                                                     ...