6.20 SummaryThis is NOT the latest copy of this book; click here for the latest version.
-
Using OOP in your PHP scripts allows you to model your code very closely after real life, which make things much easier for you. It also allows you to easily re-use code by sharing your classes.
-
PHP has a very rich OOP architecture, much of which you may never find the need to use - if __get(), __set() and other magic functions seem pointless to you, do not worry about it.
-
Use access modifiers like private and protected to make sure your data is accessed precisely as you intend for it to be accessed - do not let other programmers abuse your classes!
-
Class inheritance allows you to build up a complicated infrastructure of classes, each building on its parent - this is one of OOP's most valued features, so make good use of it.
-
If you are looking for multiple inheritance, you are looking at the wrong language - the best PHP supports is interfaces, which are a simple way to ensure a given class supports a set of functions.
|
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.
My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!
|