Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (1 vote)
2K views

Check - Circle: Thumb - Up Thumb - Down

The document describes a PHP program to create a Student class with name, roll number, and average marks data members and read and write member functions. The program defines a Student class with set and get methods for each data member and read and write methods. It then creates two Student objects, reads data into each using the read method, and writes the data using the write method.

Uploaded by

shebin mohan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
2K views

Check - Circle: Thumb - Up Thumb - Down

The document describes a PHP program to create a Student class with name, roll number, and average marks data members and read and write member functions. The program defines a Student class with set and get methods for each data member and read and write methods. It then creates two Student objects, reads data into each using the read method, and writes the data using the write method.

Uploaded by

shebin mohan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Write a PHP program to create class student with following specification Data members: Name,

Roll Num, Average Marks Member functions: Read and Write Use the above information to read
and write information of two students.

check_circle
Expert Answer

thumb_up
thumb_down
Step 1
/***********************student.php***********************/

<?php
class student
{
public $name;
public $rollNo;
public $avgMarks;

function set_name($name) {
$this->name = $name;
}
function get_name() {
return $this->name;
}

function set_rollNo($rollNo) {
$this->rollNo = $rollNo;
}
function get_rollNo() {
return $this->rollNo;
}

function set_avgMarks($avgMarks) {
$this->avgMarks = $avgMarks;
}
function get_avgMarks() {
return $this->avgMarks;

This study source was downloaded by 100000849659459 from CourseHero.com on 07-07-2022 10:27:02 GMT -05:00

https://www.coursehero.com/file/95397231/Write-a-PHP-program-to-create-class-student-with-following-specification-Data-membersdocx/
}
function read($name,$rollNo,$avgMarks){
$this->set_name($name);
$this->set_rollNo($rollNo);
$this->set_avgMarks($avgMarks);
}
function write(){
echo "<br>";
echo "Student Name : " . $this->get_name();
echo "<br>";
echo "Student Roll Number : " . $this->get_rollNo();
echo "<br>";
echo "Student Average Marks : " . $this->get_avgMarks();
echo "<br>";
}
}

$studentObj1 = new student();


$studentObj1->read('Student1','A1',75.8);
$studentObj1->write();

$studentObj2 = new student();


$studentObj2->read('Student2','A2',82.4);
$studentObj2->write();
?>
/***********************Screenshot***********************/
Step 2

This study source was downloaded by 100000849659459 from CourseHero.com on 07-07-2022 10:27:02 GMT -05:00

https://www.coursehero.com/file/95397231/Write-a-PHP-program-to-create-class-student-with-following-specification-Data-membersdocx/
This study source was downloaded by 100000849659459 from CourseHero.com on 07-07-2022 10:27:02 GMT -05:00

https://www.coursehero.com/file/95397231/Write-a-PHP-program-to-create-class-student-with-following-specification-Data-membersdocx/
Powered by TCPDF (www.tcpdf.org)

You might also like