Repository navigation
Expand file tree
/
Copy pathbasics.php
More file actions
80 lines (64 loc) · 2.56 KB
/
Copy pathbasics.php
File metadata and controls
80 lines (64 loc) · 2.56 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
ini_set('display_errors', 1);
class monitor { //class name
public $name; // variable name
public $brand;
public $price;
public $size;
public $color;
public $resolution;
private $refresh_rate;
protected $weight;
public function basic_info() { // function names
$this->name = "LG monitor"; // set value for the variable
$this->brand = "LG";
$this->price = "6000";
$this->size = "22 inch";
$this->color = "black";
// return $this->name; // return value
return ($this->name . "<br>" . $this->brand . "<br>" . $this->price . "<br>" . $this->size . "<br>" . $this->color); // return value
// return ($this->name . "LG monitor <br>" . $this->brand . "LG <br>" . $this->price . "Rs.6000 <br>" . $this->size . "22inch <br>" . $this->color); // return value
}
private function resolution_info() { // function name
$this->resolution = "1920x1080"; //variable name for this function
return $this->resolution;
}
function get_resolution() { // function name
$this->resolution1 = "1080x920"; //variable name for this function
return $this->resolution_info();
return $this->resolution1;
}
// constructor
function __construct($name1) { // function name
$this->name1 = $name1; // variable name
return $this->name1;
}
private function get_refresh_rate() { // function name
$this->refresh_rate = "100HZ";
return $this->refresh_rate;
}
function get_weight() { // function name
return $this->weight;
}
}
$monitor_info = new monitor("HP"); // object name (parameter value for constructor)
echo $monitor_info->basic_info(); // call function
echo '<br>';
echo $monitor_info->get_resolution(); // call function
echo '<br>';
class monitor1 extends monitor {
function basic_info() {
$this->name = "Samsung monitor";
$this->brand = "Samsung";
$this->price = "7000";
$this->size = "24 inch";
$this->color = "white";
$this->resolution = "1920x1080";
$this->refresh_rate = "120HZ";
$this->weight = "4000 grams";
return $this->name;
}
}
$monitor_info1 = new monitor1("Lenovo"); // object name (parameter value for constructor)
echo $monitor_info1->basic_info(); // call function
?>