











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












th
Resource
APHPscriptstartswith:
ThedefaultfileextensionforPHPfilesis".php".
dividestheoperatorsinthefollowinggroups: Arithmeticoperators Assignmentoperators Comparisonoperators Increment/Decrementoperators Logicaloperators Stringoperators Arrayoperators Conditionalassignmentoperators
differentconditions.Usetheswitchstatementtoselectoneofmanyblocks ofcodetobeexecuted. Syntax switch(n){ caselabel1: codetobeexecutedifn=label 1 ; break; caselabel2: codetobeexecutedifn=label 2 ; break; caselabel3: codetobeexecutedifn=label 3 ; break; ... default: codetobeexecutedifnisdifferentfromalllabels; }
true,performsafunctionordisplaysinformation.Belowisageneralexample ofanifstatement,notspecifictoanyparticularprogramminglanguage. if(X< 10 ){ print"HelloJohn"; }
"; echo"perimeterofshapeis$length*$width=".( 2 *($length+$width)). ""; ?>
$x 1 =(-$b+sqrt($D))/( 2 *$a); $x 2 =(-$b-sqrt($D))/( 2 *$a); echo"Rootsare:$x 1 ,$x 2 \n"; }else{ $x 1 =-$b/( 2 $a); $x 2 =sqrt(-$D)/( 2 $a); echo"Rootsare:$x 1 ±$x 2 i\n"; } } echo"Equationisxx+ 5 x+ 4 = 0 \n"; roots( 1 , 5 , 4 ); echo"\nEquationisxx+ 4 x+ 5 = 0 \n"; roots( 1 , 4 , 5 ); ?> Output:
Equationisxx+ 5 x+ 4 = 0 Rootsare:- 1 ,- 4 Equationisxx+ 4 x+ 5 = 0 Rootsare:- 2 ± 1 i
$x 1 =(-$b+sqrt($D))/( 2 $a); $x 2 =(-$b-sqrt($D))/( 2 $a); echo"Rootsare:$x 1 ,$x 2 \n"; }else{ $x 1 =-$b/( 2 $a); $x 2 =sqrt(-$D)/( 2 $a); echo"Rootsare:$x 1 ±$x 2 i\n"; } } echo"Equationisxx+ 5 x+ 4 = 0 \n"; roots( 1 , 5 , 4 ); echo"\nEquationisxx+ 4 x+ 5 = 0 \n"; roots( 1 , 4 , 5 ); ?> Output: Equationisxx+ 5 x+ 4 = 0 Rootsare:- 1 ,- 4 Equationisxx+ 4 x+ 5 = 0 Rootsare:- 2 ± 1 i
"); for($i= 1 ;$i<= 10 ;$i++){ echo("$num" ."X"."$i"."=" .$num*$i."
"); } } ?> Output:n"; echo$n 1 .''.$n 2 .''; while($num< 10 ) {
$n 3 =$n 2 +$n 1 ; echo$n 3 .''; $n 1 =$n 2 ; $n 2 =$n 3 ; $num=$num+ 1 ; ?> Output:
{ $factorial=$factorial*$x; } echo"Factorialof$numis$factorial"; ?> Output:
$marks= 40 ; if($marks>= 60 ) { $grade="FirstDivision"; } elseif($marks>= 45 ) { $grade="SecondDivision"; } elseif($marks>= 33 ) { $grade="ThirdDivision"; } else { $grade="Fail"; } echo"Studentgrade:$grade"; ?> Output: ThirdDivision.
{ $grade="FirstDivision"; } elseif($marks>= 45 ) { $grade="SecondDivision"; } elseif($marks>= 33 ) { $grade="ThirdDivision"; } else { $grade="Fail"; } echo"Studentgrade:$grade"; ?> Output: Thirddivision.
if($flag== 0 ){ echo$MyString."isaPalindromestring.\n"; }else{ echo$MyString."isnotaPalindromestring.\n"; } } Palindrome("radar"); Palindrome("rubber"); Palindrome("malayalam"); ?> Output: radarisaPalindromestring. rubberisnotaPalindromestring. malayalamisaPalindromestring.
#include main(){ inti,j,n; charstr[ 100 ][ 100 ],s[ 100 ]; printf("Enternumberofnames: n"); scanf("%d",&n);
printf("Enternamesinanyorder:\n"); for(i= 0 ;i 0 ) { strcpy(s,str[i]); strcpy(str[i],str[j]); strcpy(str[j],s); } } } printf("\nThesortedorderofnamesare:\n"); for(i= 0 ;i
FilesUploadandDownload
UploadFile upload