-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionInPHP.php
More file actions
44 lines (41 loc) · 998 Bytes
/
functionInPHP.php
File metadata and controls
44 lines (41 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
class student{
var $id;
var $name;
var $faculty;
var $program;
var $semester;
function getData($key){
return $this->$key;
}
function setData($key,$value){
$this->$key=$value;
return $this;
}
function print(){
echo "<hr>";
echo "student id:".$this->getData("id");
echo "<br> student name:".$this->getData("name");
echo "<br> faculty:".$this->getData("faculty");
echo "<br> program:".$this->getData("program");
echo"<br> faculty:".$this->getData("faculty");
echo"<br>semester:".$this->getData("semester");
}
}
$std1=new student();//object creation
$std2=new student();
//student 1 info
$std1->setData("id",1);
$std1->setData("name","Greesma");
$std1->setData("faculty","management");
$std1->setData("program","BIM");
$std1->setData("semester",4);
$std1->print();
//student 2 info
$std2->setData("id",2);
$std2->setData("name","Asmita");
$std2->setData("faculty","science");
$std2->setData("program","BSCCSIT");
$std2->setData("semester",4);
$std2->print();
?>