From 962b413925ddc925e480839f0185bc067ec98437 Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Wed, 20 Oct 2010 10:25:27 +0000 Subject: [PATCH] Fixed bug #51381 (Clarify class definition order importance for multiple levels of inheritance) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@304561 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/oop5/inheritance.xml | 172 ++++++++++++++++++---------------- 1 file changed, 91 insertions(+), 81 deletions(-) diff --git a/language/oop5/inheritance.xml b/language/oop5/inheritance.xml index 1c8ed82b19..be546a2ba9 100644 --- a/language/oop5/inheritance.xml +++ b/language/oop5/inheritance.xml @@ -1,81 +1,91 @@ - - - - Object Inheritance - - Inheritance is a well-established programming principle, and PHP makes use - of this principle in its object model. This principle will affect the way - many classes and objects relate to one another. - - - For example, when you extend a class, the subclass inherits all of the - public and protected methods from the parent class. Unless a class overrides - those methods, they will retain their original functionality. - - - This is useful for defining and abstracting functionality, and permits the - implementation of additional functionality in similar objects without the - need to reimplement all of the shared functionality. - - - - Inheritance Example - -printItem('baz'); // Output: 'Foo: baz' -$foo->printPHP(); // Output: 'PHP is great' -$bar->printItem('baz'); // Output: 'Bar: baz' -$bar->printPHP(); // Output: 'PHP is great' - -?> -]]> - - - - - - + + + + Object Inheritance + + Inheritance is a well-established programming principle, and PHP makes use + of this principle in its object model. This principle will affect the way + many classes and objects relate to one another. + + + For example, when you extend a class, the subclass inherits all of the + public and protected methods from the parent class. Unless a class overrides + those methods, they will retain their original functionality. + + + This is useful for defining and abstracting functionality, and permits the + implementation of additional functionality in similar objects without the + need to reimplement all of the shared functionality. + + + + + Inheritance Example + +printItem('baz'); // Output: 'Foo: baz' +$foo->printPHP(); // Output: 'PHP is great' +$bar->printItem('baz'); // Output: 'Bar: baz' +$bar->printPHP(); // Output: 'PHP is great' + +?> +]]> + + + + + + + Unless autoloading is used, then classes must be defined before they are + used. If a class extends another, then the parent class must be declared + before the child class structure. This rule applies to class that inherit + other classes and interfaces. + + + + +