-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc12.php
89 lines (65 loc) · 1.25 KB
/
c12.php
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
81
82
83
84
85
86
87
88
89
<?php
class Test {
public function __set($name, $value){
echo "Setting <b>$name</b> to <b>$value</b>";
}
public function __get($name){
return 'Pero';
}
}
// $t = new Test;
// // $t->pero= 'test 123';
// echo $t->ime;
// echo '<br>';
// echo $t->prezime;
// echo '<br>';
// echo $t->den_na_ragjanje;
// echo '<br>';
class Test2 {
private $vars = array();
public function __set($name, $value){
$this->vars[$name] = $value;
}
public function __get($name){
return $this->vars[$name];
}
}
$t2 = new Test2;
$t2->ime = 'elena';
$t2->prezime='stojanova';
$t2->vozrast=22;
print_r($t2);
class Test3{
private $boja='zelena';
private $visina = 10;
public function __get($b){
if(property_exists($this, $b)){
return $this->$b;
}else {
return false;
}
}
}
// $t3= new Test3;
// echo $t3->boja;
// echo $t3->visina;
class Test4{
public function __call($name, $args){
echo 'Method: '.$name.', Arguments: '.implode(', ', $args);
}
}
// $t4 = new Test4;
// $t4->brmbrm();
// echo '<br>';
// $t4->test('Pero', 'Janko', 'Stanko');
// echo '<br>';
// $t4->mjau();
class StaticClass{
public static $string;
public static function length(){
return strlen(self::$string);
}
}
staticClass::$string = 'Hello world';
echo StaticClass::length();
?>