







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Program based Global Variable of PHP for BCA and BSC(Computer Science)
Typology: Study notes
1 / 13
This page cannot be seen from the preview
Don't miss anything!








1. Write a PHP program to create a simple calculator that can accept two numbers and perform operations like add, subtract, multiplication and divide (using Self Processing form).
Enter first no : Enter second no : Select Operation which u have to perform :
addition=".$add.""; break;
case 2:$sub=$no1-$no2; echo "subtraction=".$sub.""; break;
case 3:$mult=$no1*$no2; echo "multiplication=".$mult.""; break;
case 4:$div=$no1/$no2; echo "division=".$div.""; break;
else echo "Please enter both 2 nos"; } else die("not able to acccess"); ?>
1/2/3 for respective yearlast three are for actual roll no.
Php file : ";$fac=substr($roll_no,0,2); if($fac==11) echo "Faculty is B.Sc"; else if($fac==12) echo "Faculty is Bcom"; else if($fac==13) echo "Faculty is BA"; $year=substr($roll_no,2,1); if($year==1) echo "Year is First Year"; else if($year==2) echo "Year is Second Year"; else if($year==3) echo "Year is Third Year"; echo "Your Roll No. is".substr($roll_no,3)."";
. Write a Calculator class that can accept two values, then add them, subtract them, multiply them together, or divide them on request. For example: $calc = new Calculator( 3, 4 ); echo $calc- >add(); // Displays “7” echo $calc- >multiply(); // Displays “12” html file :
Enter No1 Enter No2Name : Address : Mobile No :
Php file :
Enter LIC Information :
Policy no. : Policy Name : Premium :
Php file : Employee Details ";
echo "Name : ".$_COOKIE['emp1'].""; echo "Address : ".$_COOKIE['emp2'].""; echo "Mobile No. : ".$_COOKIE['emp3']."";
echo "Policy no. : ".$_POST['p_no'].""; echo "Policy Name : ".$_POST['p_name'].""; echo "Premium : ".$_POST['premium'].""; ?>
echo “You accessed this page $_COOKIE['cnt'] times”;
?>
slip12
{$sum=0; while($n) { $r=$n%10; $sum=$sum+$r; $n=$n/10; } $n=$sum; } return $n; } echo fact($_POST['txtnumber']); echo ""; echo singleval($_POST['txtnumber']); } ?>
echo "Capitalization of each word of each name :".ucwords($nm);
$e=explode('@',$eid);
If (count($e)==2) { echo "Email id contains @ symbol "; } else echo "email id doesn’t contains @ symbol or contains more @ symbol";
Enter String :
".$nstr; } ?>
20. Write PHP program to select list of subjects (use multivalued parameter) displays on next page. HTML File
Slip Select List of subjectsPHP File "; foreach($_GET['subjects'] as $s) { echo "$s"; }
?>
21. Write a PHP program for the followi2qang create a calculator that can store two values and perform operations like add, subtract, multiplication and divide (using Self Processing form) Php file :
Enter first no : Enter second no : Select Operation which u have to perform :
"; echo "$msg"; echo "";
"; foreach($_SERVER as $k=>$v) { echo"".$k."".$v.""; } echo""; ?>
Html file :
Enter Username : Enter Password :
Php file :
slip_4-1.php :
enter ur details
Enter Name : Enter City :
Enter Phone No :
Invalid Username Or Password" ?>
slip_4-2.php : Page Time Expired"; else { echo "Name : ".$_REQUEST['uname'].""; echo "City : ".$_REQUEST['city'].""; echo "Phone NO : ".$_REQUEST['pno'].""; session_destroy(); } ?>
10. Create a form to accept student information (name, class, address). Once the student information is accepted, accept marks in next form (Java, PHP, ST, IT, pract1, and project). Display the mark sheet for the student in the next form containing name, class, marks of the subject, total and percentage(Use $_COOKIE).
Html file :
Enter Students information :
Name : Address : Class :
Php file : Slip_10-1.php :
Enter Marks for Student: