0% found this document useful (0 votes)
14 views11 pages

PHP PR 1,2,3 (22203C0007)

The document outlines a laboratory course on Web Based Application Development with PHP for 6th semester Computer Engineering students. It includes various experiments focusing on PHP programming, such as creating a grading system, implementing loops, and generating reports based on student grades. Each experiment provides code examples and expected outputs to guide students in their practical learning experience.

Uploaded by

adityadarekar919
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views11 pages

PHP PR 1,2,3 (22203C0007)

The document outlines a laboratory course on Web Based Application Development with PHP for 6th semester Computer Engineering students. It includes various experiments focusing on PHP programming, such as creating a grading system, implementing loops, and generating reports based on student grades. Each experiment provides code examples and expected outputs to guide students in their practical learning experience.

Uploaded by

adityadarekar919
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

DEPARTMENT OF COMPUTER ENGINEERING

Subject: Web Based Application Subject Code: 22619


Development with PHP

Semester: 6th Semester Course: Computer Engineering

Laboratory No: L001C Name of Subject Teacher: Prof. Sneha


Patange

Name of Student: Aditya Darekar Roll Id: 22203C0007

Experiment Title of Experiment Application


No:
1 a. Install and configure PHP, web A) Write PHP program to implement basic
server, MYSQL PHP functions (echo, print, var_dump).
b. Write a program to print
“Welcome to PHP” B) STUDENT GRADE CALCULATOR-
c. Write a simple PHP program Create a script to manage and analyse a
using expressions and operators. class. The script should achieve the
2 Write a php program to following objectives:
demonstrate the use of decision • Input grades: Assume grades are
making control statement integers ranging from 1 to 100
• If statement • Grade classification: Classification
• If else statement done on following categories:
• Switch A - 85 to 100
3 Write a PHP program to A - 70 to 85
demonstrate the use of Looping A - 50 to 70
structures using- A - 45 to 50
F below 45
a) While statement Generate a summary report once the input
b) Do-while statement is complete, and save it into a text file
c) For statementa php program which should include:
• Total no. of students
• Number of students in each grade
category
• The class average
• The highest and lowest grade

C) Write PHP programs to implement for


loop to print Fibonacci series and prime
number
Program code
• Write a PHP script to differentiate between echo and print in php

Code
<?php
$var1 = 50;
$var2 = "percentage";
$var4 = "Demo";
echo "Student $var2 is $var1 ";
print "Demo text from print ";
print "Student " .$var2. " is " .$var1. "";
echo print "Hello " .$var4. "";
?>

Output:-

• Write a php script to demonstrate use of var_dump in php

Code
<?php
$var1 = 50;
$var2 = "percentage";
$var4 = 65.5;
$var3 = array("Demo text",65,65.5);
echo "Array var_dump <br>";
var_dump($var3);
echo "<br>";
echo "String var_dump <br>";
var_dump($var2);
echo "<br>";
echo "Integer var_dump <br>";
var_dump($var1);
echo "<br>";
echo "Float var_dump <br>";
var_dump($var4);
?>

Output

• Write a PHP script to create grading system

Code
<?php
$grade = "";
$name=readline("Enter your name:");
$marks=readline("Enter your marks:");

if($marks>=35&&$marks<=60)
{
$grade="C";
}
elseif($marks>=61&&$marks<=75)
{
$grade="B";
}
elseif($marks>=76&&$marks<91)
{
$grade="A";
}
elseif($marks>=91&&$marks<=100)
{
$grade="A+";
}
else
{
$grade="F";
}
echo "Your grade is $grade \n";
?>

Output

• Write a PHP script to create grading system with continuous looping until
user decides to exit

Code

<?php
$ch = "yes";
$grade = "";
do
{
$name=readline("Enter your name:");
$marks=readline("Enter your marks:");

if($marks>=35&&$marks<=60)
{
$grade="C";
}
elseif($marks>=61&&$marks<=75)
{
$grade="B";
}
elseif($marks>=76&&$marks<91)
{
$grade="A";
}
elseif($marks>=91&&$marks<=100)
{
$grade="A+";
}
else
{
$grade="F";
}
$output_txt = "Name " .$name. " Roll no " .$roll. " Grade " .$grade. "\n";
echo "$output_txt";
$file = fopen("Demo.txt","a");
fwrite($file,$output_txt);
fclose($file);
$ch = readline("Do you want to continue type yes or no: ");
} while($ch == "yes");
?>

Output

• Grading System for Calculating


• Total no of students
• Average marks of class
• Highest Marks
• Lowest Marks
• Grade Wise count
Code

<?php
$ch = "yes";
$total_students = 0;
$total_marks = 0;
$highest_marks = 0;
$lowest_marks = 100;
$grade_count = ["A+" => 0, "A" => 0, "B" => 0, "C" => 0, "F" => 0];

$file = fopen("Demo.txt", "a");

do {
$name = readline("Enter your name: ");
$roll = readline("Enter roll no: ");
$marks = readline("Enter your marks: ");

$total_students++;
$total_marks += $marks;

if ($marks > $highest_marks) {


$highest_marks = $marks;
}
if ($marks < $lowest_marks) {
$lowest_marks = $marks;
}

if ($marks >= 91) {


$grade = "A+";
} elseif ($marks >= 76) {
$grade = "A";
} elseif ($marks >= 61) {
$grade = "B";
} elseif ($marks >= 35) {
$grade = "C";
} else {
$grade = "F";
}

$grade_count[$grade]++;

echo "Name: $name Roll No: $roll Grade: $grade\n";

$output_txt = "Name: $name Roll No: $roll Grade: $grade\n";


fwrite($file, $output_txt);

$ch = readline("Do you want to continue? Type yes or no: ");


} while ($ch == "yes");

if ($total_students > 0) {
$class_average = $total_marks / $total_students;
$final_stats = "\nTotal students: $total_students\n";
$final_stats .= "Class average: " . number_format($class_average, 2) . "\n";
$final_stats .= "Highest marks: $highest_marks\n";
$final_stats .= "Lowest marks: $lowest_marks\n";
$final_stats .= "Grade-wise count:\n";
$final_stats .= "A+: " . $grade_count["A+"] . "\n";
$final_stats .= "A: " . $grade_count["A"] . "\n";
$final_stats .= "B: " . $grade_count["B"] . "\n";
$final_stats .= "C: " . $grade_count["C"] . "\n";
$final_stats .= "F: " . $grade_count["F"] . "\n";

echo $final_stats;

fwrite($file, $final_stats);
} else {
echo "No students entered.\n";
fwrite($file, "No students entered.\n");
}

fclose($file);
?>

Output
6 Write a program for printing fibonnaci series of number

Code
<?php
$n=readline("enter the number for fibonnaci series");
$num1 = 0;
$num2 = 1;
for ($i = 0; $i < $n; $i++) {
print($num1 . ", ");
$num3 = $num1 + $num2;
$num1 = $num2;
$num2 = $num3;
}
?>

Output

7 Write a program to print Prime no in range of 10

Code
<?php
for ($i = 2; $i <= 10; $i++) {
$prime = true;
for ($j = 2; $j < $i; $j++) {
if ($i % $j == 0) {
$prime = false;
break;
}
}
if ($prime) {
print($i." is a prime number\n");
}}
?>

Output
Grade and Process Related Product Related Dated Sign
Dated (15) (10)
Signature
of Teacher

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy