-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoops.php
More file actions
63 lines (38 loc) · 812 Bytes
/
Copy pathoops.php
File metadata and controls
63 lines (38 loc) · 812 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/*
class class1{
public $x = 1;
function fun1(){
return $this->x++;
}
}
$obj1 = new class1();
$obj1->fun1();
$obj2 = new class1();
echo $obj1->x;
echo "<br>";
echo $obj2->x;
echo "<br>";
*/
// If you create a __construct() function, PHP will automatically call this function when you create an object from a class.
// A destructor is called when the object is destructed or the script is stopped or exited.
class test{
function __construct($y) {
$this->x=$y;
}
function incval() {
$this->x++;
}
function getX() {
return $this->x;
}
// function __destruct() {
// echo "end";
// }
}
$objTest = new test(15);
$objTest->incval();
$objTest->incval();
$objTest->incval();
echo $objTest->getX();
?>