-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
58 lines (45 loc) · 1.08 KB
/
test.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
<?php
class Person {
private $name;
private $age;
// Constructor
public function __construct($name, $age) {
$this->name = $name;
$this->age = $age;
}
// Method to set the name
public function setName($name) {
$this->name = $name;
}
// Method to get the name
public function getName() {
return $this->name;
}
// Method to set the age
public function setAge($age) {
$this->age = $age;
}
// Method to get the age
public function getAge() {
return $this->age;
}
// Method to display person details
public function display() {
echo "Name: " . $this->name . ", Age: " . $this->age . "\n";
}
}
// Main function to demonstrate the usage
function main() {
// Create a Person object
$person = new Person("John Doe", 30);
// Display initial details
$person->display();
// Modify the person's details
$person->setName("Jane Doe");
$person->setAge(25);
// Display updated details
$person->display();
}
// Run the main function
main();
?>