... | @@ -9,6 +9,8 @@ this lab has three exercises. |
... | @@ -9,6 +9,8 @@ this lab has three exercises. |
|
|
|
|
|
## 1. basic classes
|
|
## 1. basic classes
|
|
|
|
|
|
|
|
a note on naming conventions: it is typical to use PascalCase for classes, camelCase for methods (& properties) and lower_case for variables & functions. Whatever conventions you use, try to use them consistently.
|
|
|
|
|
|
1.1 the basic definition is given in the php manual http://php.net/manual/en/language.oop5.basic.php
|
|
1.1 the basic definition is given in the php manual http://php.net/manual/en/language.oop5.basic.php
|
|
create a class for an object of your choice (person, pet, planet - it's up to you). define a few attributes and methods. write a script that instantiates this class and invokes one of its methods.
|
|
create a class for an object of your choice (person, pet, planet - it's up to you). define a few attributes and methods. write a script that instantiates this class and invokes one of its methods.
|
|
|
|
|
... | @@ -19,5 +21,7 @@ extend your class in two ways, and show that you can use them. |
... | @@ -19,5 +21,7 @@ extend your class in two ways, and show that you can use them. |
|
|
|
|
|
1.4 overriding in php (modifying an inherited method) is easy: you just need to create method with same name in your child class which you want to override. Do this for your two new classes and demonstrate that you have created two different methods which are invoked the same way.
|
|
1.4 overriding in php (modifying an inherited method) is easy: you just need to create method with same name in your child class which you want to override. Do this for your two new classes and demonstrate that you have created two different methods which are invoked the same way.
|
|
|
|
|
|
|
|
1.5 demonstrate that autoloading of your classes works. note that it is now recommended to use spl_autoload_register() rather than __autoload() http://php.net/manual/en/language.oop5.autoload.php
|
|
|
|
|
|
|
|
|
|
|
|
|