-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_Encapsulation.php
More file actions
68 lines (48 loc) · 1.25 KB
/
Copy path03_Encapsulation.php
File metadata and controls
68 lines (48 loc) · 1.25 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
<?php
class Class1
{
public $num; //Everyone can access this PUBLIC value
private $num1; //NO class and no external can access this PRIVATE value
protected $num2; //only other class can exten this PROTECTED value
public $name;
public function __construct()
{
$this->num = 100;
$this->num1 = 2;
$this->num2 = 4;
// echo $this->name = "HELO.<br>";
}
public function getFun()
{
echo "<br/>" . $this->num1;
}
}
$out = new Class1();
// echo "<br/>" . $out->num1 = 9; //but,
// echo $out->getFun();
class Class2 extends Class1
{
//public function getFun()
// {
// // return $this->num;
// // return $this->num1;
// return $this->num2;
// echo "We can access this function outside the class";
// }
// private function getFun()
// {
// return $this->num2;
// echo "We cant access this function outside the class";
// }
// protected function getFun()
// {
// return $this->num2;
// echo "We cant access this function outside the class";
// }
}
$er = new Class2();
echo $er->getFun();
echo "<br/> ACCESS ASSISSFIRE :: <br>PUBLIC <br>PROTECTED <br>PRIVATE ";
// public
// protected
// private