- Document that order of class definition is important (closes #13165).

# Though the zend engine CAN handle class definitions not in the right order
# this is not always true, especially when extending classes which extend
# classes.  See the report.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@85237 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Markus Fischer 2002-06-10 08:43:11 +00:00
parent e7457b50e7
commit bed4bd6c00

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.34 $ -->
<!-- $Revision: 1.35 $ -->
<chapter id="language.oop">
<title>Classes and Objects</title>
@ -255,6 +255,25 @@ $ncart->add_item("10", 1); // (inherited functionality from cart)
</programlisting>
</informalexample>
<para>
This is also called a "parent-child" relationship. You create a class,
parent, and use <literal>extends</literal> to create a new class
<emphasis>based</emphasis> on the parent class: the child class. You can
even use this new child class and create another class based on this child
class.
</para>
<note>
<para>
Classes must be defined before they are used! If you want the class
<literal>Named_Cart</literal> to extend the class
<literal>Cart</literal>, you will have to define the class
<literal>Cart</literal> first. If you want to create another class called
<literal>Yellow_named_cart</literal> based on the class
<literal>Named_Cart</literal> you have to define
<literal>Named_Cart</literal> first. To make it short: the order in which
the classes are defined is important.
</para>
</note>
</sect1>
<sect1 id="language.oop.constructor">