I have the following three objects which includes the following methods and properties:
$obj1
- $prop1
- $prop2
- $prop3
- $prop4
- method1()
- method2()
- method3()
- method4()
$obj2
- $prop2
- $prop3
- $prop4
- $prop5
- method2()
- method3()
- method4()
- method5()
$obj3
- $prop1
- $prop3
- $prop4
- $prop5
- method1()
- method3()
- method4()
- method5()
All properties and methods of a given name utilize identical script to create them.
One possible script to create these objects is as follows:
class class1 {
var $prop1=123, $prop2=array(), $prop3, $prop4;
public method method1($x) {echo('hello '.$x;}
public method method2($x) {echo('goodby '.$x;}
public method method3($x) {echo('hey '.$x;}
public method method4($x) {echo('seeya '.$x;}
}
class class2 {
var $prop2=array(), $prop3, $prop4, $prop5=555,;
public method method2($x) {echo('goodby '.$x;}
public method method3($x) {echo('hey '.$x;}
public method method4($x) {echo('seeya '.$x;}
public method method5($x) {echo('latter '.$x;}
}
class class3 {
var $prop1=123, $prop3, $prop4, $prop5=555,;
public method method1($x) {echo('hello '.$x;}
public method method3($x) {echo('hey '.$x;}
public method method4($x) {echo('seeya '.$x;}
public method method5($x) {echo('latter '.$x;}
}
How can I create these three objects without duplicating the script used to create the properties and methods?