Page 328 - Computer Software Application TP - Volume 1
P. 328
COMPUTER SOFTWARE APPLICATION - CITS
$this->name = $name;
$this->age = $age;
echo “Constructor called\n”;
}
// Method to display information
public function displayInfo()
{
echo “Name: “ . $this->name . “, Age: “ . $this->age . “\n”;
}
}
// Creating an object of MyClass
$obj = new MyClass(“John”, 30);
// Calling method to display information
$obj->displayInfo();
?>
</body>
</html>
3 Save the program in C:\Apache24\htdocs in a folder with .php extension
4 Run the Apache services from windows services
5 Open the browser and type the following address
http://localhost/foldername/
6 Click the php file to run and verify the output
TASK 3: Object destructors
1 Open the text editor
2 Write the following codes
<html >
<head>
<title> destructors</title>
</head>
313
CITS : IT & ITES - Computer Software Application - Exercise 59 CITS : IT & ITES - Computer Software Application - Exercise 59