PHP Tutorials

PHP Searching and Sorting in Array 0

PHP Searching and Sorting in Array

Program 1 <html> <head><title>Array in PHP Application</title> <body> <pre> <center> <?php $numbers=array(10,5,6,12,56,77,89); $s=12; $temp=false; for($i=0;$i<count($numbers);$i++) { if($s==$numbers[$i]) { $temp=true; break; } } if($temp==true) echo “<br><font color=green size=5> Searching success</font>”; else echo “<br><font color=red size=5>...

Array in PHP with Examples 0

Array in PHP with Examples

Program 1 <html> <head><title>Array in PHP Application</title> <body> <pre> <center> <?php $numbers=array(10,20,30,40,50,34,55,77,23,88); $sum=0; for($i=0;$i<count($numbers);$i++) { echo “<li>”.$numbers[$i].”</li>”; $sum+=$numbers[$i]; } echo ” <br> Total is “.$sum; // Reverse order // how many even and numbers...

Anonymous Function in PHP 0

Anonymous Function in PHP

Program 1 <html> <head><title>PHP For Loops</title> <body> <center> <?php // Function as variable function myFunction($name) { echo “Hello “.$name.” Data Flair Free Course”; } // Calling //myFunction(); $display=”myFunction”; $display(“Vivek “); ?> </center> </body> </html>...

PHP Variable Argument Function 0

PHP Variable Argument Function

Program 1 <html> <head><title>PHP Var args</title> <body> <center> <?php function myDisplay(…$values) // var args { $sum=0; for($i=0;$i<count($values);$i++) { echo $values[$i]; $sum=$sum+$values[$i]; echo “<br>”; } echo “Sum is: “.$sum; } myDisplay(50,20,28,10,34,67,44,77,88,99); echo “<br>——————————————<br>”; myDisplay(110,120,128,130,324,); ?>...

Call by Reference in PHP 0

Call by Reference in PHP

Program 1 <html> <head><title>PHP For Loops</title> <body> <center> <?php function swap(&$a,&$b) // copy in local { $c=$a; $a=$b; $b=$c; } // call main $a=50; $b=30; echo “<br> Before Swaping: “.$a.” “.$b; swap($a,$b); // call...

Call by Value in PHP with Examples 0

Call by Value in PHP with Examples

Program 1 <html> <head><title>PHP For Loops</title> <body> <center> <?php function display() // defination { echo “Data Flair Free Course”; echo “<br>Data Flair Free Certificate course”; } /* function inbuild (derived) userdefine defination calling */...

For Loop in PHP with Examples 0

For Loop in PHP with Examples

Program 1 <html> <head><title>PHP For Loops</title> <body> <center> <?php // for($i=1;$i<=10;$i++) // i =3 // { // echo “<br>”.$i; // } // $i=1; // for(;$i<=10;$i++) // { // echo “<br>”.$i; // } // for($i=1;$i<=10;)...

While Loop in PHP 0

While Loop in PHP

Program 1 <html> <head><title>PHP Loops</title> <body> <center> <?php // $i=1; // intilization // $n=23; // echo “Table of=”.$n; // while($i<=10) //condition // { // echo”<br> “.$i*$n; // ++$i; // increment // } /* 1...

PHP Switch Statement 0

PHP Switch Statement

Program 1 <html> <head><title>PHP Relational Operators</title> <body> <center> <?php $ch=’B’; switch($ch) { case ‘a’: case ‘e’: case ‘i’: case ‘o’: case ‘u’: case ‘A’: case ‘E’: case ‘I’: case ‘O’: case ‘U’: echo “VOWEL”;...