/
references.php
72 lines (52 loc) · 1.15 KB
/
references.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
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
function references($a) {
echo "Truyen kieu tham tri" . $a;
}
references(5);
echo "========================" . "<br />";
function add_some_extra(&$string) {
$string .= 'and something extra.';
}
$str = 'This is a string, ';
add_some_extra($str);
echo $str; // xuất ra là 'This is a string, and something extra.'
echo "========================" . "<br />";
echo "============ Truyen tham chieu =========" . "<br />";
function count_1(&$var) {
$var++;
}
$b = 5;
count_1($b);
echo $b;
// kết quả sẽ là 6
echo "<br />";
echo "============ Truyen tham tri =========" . "<br />";
function count_2($var) {
$var++;
}
$c = 5;
count_2($c);
echo $c;
// kết quả sẽ là 5
?>
<?php
class cha {
public $ten_cha = "toi la cha";
public function test() {
echo $this->ten_cha . "<br />";
}
}
class con extends cha {
public $ten_con = 'toi la con';
public function test() {
parent::test(); //phuong thuc test la cua class cha
echo $this->ten_con . "<br />";
}
}
$a = new con;
$a->test();
?>