Page 336 - Computer Software Application TP - Volume 1
P. 336
COMPUTER SOFTWARE APPLICATION - CITS
{
echo “myMethod does not exist in MyClass. <br/>”;
}
?>
</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 5: Object serialization
1 Open the text editor
2 Write the following codes
<html >
<head>
<title> Object serialization </title>
</head>
<body>
<?php
// Define a class
class MyClass
{
public $name;
public $age;
public function __construct($name, $age)
{
$this->name = $name;
$this->age = $age;
}
}
// Create an object of MyClass
$obj = new MyClass(“John”, 30);
321
CITS : IT & ITES - Computer Software Application - Exercise 60 CITS : IT & ITES - Computer Software Application - Exercise 60