CVS update: php3/doc/chapters

From: Date: Wed, 09 Sep 1998 11:40:16 +0000
Subject: CVS update: php3/doc/chapters
Groups: php.dev 
Request: Send a blank email to php-dev+get-28@lists.php.net to get a copy of this message
Date: Wednesday September 9, 1998 @ 7:40 Author: eschmid Update of /repository/php3/doc/chapters In directory asf:/tmp/cvs-serv24976 Modified Files: lang-const.sgml Log Message: Some corrections to SGML Index: php3/doc/chapters/lang-const.sgml diff -c php3/doc/chapters/lang-const.sgml:1.21 php3/doc/chapters/lang-const.sgml:1.22 *** php3/doc/chapters/lang-const.sgml:1.21 Sat Aug 8 08:36:18 1998 --- php3/doc/chapters/lang-const.sgml Wed Sep 9 07:40:16 1998 *************** *** 776,790 **** <para> This is a deprecated feature, and should only be used by the PHP/FI2->PHP3 convertor. <sect1 id="keyword.class"> <title>CLASS</title> ! <simpara> ! A class is a collection of variables and functions working with this variables. ! A class is defined using syntax such as the following: <informalexample> ! <programlisting> class Cart { var items; // Items in our shopping cart --- 776,793 ---- <para> This is a deprecated feature, and should only be used by the PHP/FI2->PHP3 convertor. + </sect1> <sect1 id="keyword.class"> <title>CLASS</title> ! <para> ! A class is a collection of variables and functions working with ! this variables. A class is defined using syntax such as the ! following: <informalexample> ! <programlisting role=php> ! &lt;?php class Cart { var items; // Items in our shopping cart *************** *** 803,833 **** } } } </programlisting> </informalexample> ! This defines a class named Cart that consists of an associative array of articles in the cart ! and two functions to add and remove items from this cart. ! ! Classes are types, that is, they are blueprints for actual variables. You have to create a ! variables of the desired type with the new operator. <informalexample> ! <programlisting> $cart = new Cart; $cart->add_item("10", 1); </programlisting> </informalexample> ! This creates an object $cart of the class Cart. The function add_item() of that object is ! being called to add 1 item of article number 10 to the cart. ! ! Classes can be extensions of other classes. The extended or derived class has all ! variables and functions of the base class and what you add in the extended defintion. ! This is done using the extends keyword. <informalexample> ! <programlisting> class Named_Cart extends Cart { var $owner; --- 806,845 ---- } } } + ?> </programlisting> </informalexample> ! <para> ! This defines a class named Cart that consists of an associative ! array of articles in the cart and two functions to add and remove ! items from this cart. ! </para><para> ! Classes are types, that is, they are blueprints for actual ! variables. You have to create a variables of the desired type with ! the new operator. ! </para> <informalexample> ! <programlisting role=php> $cart = new Cart; $cart->add_item("10", 1); </programlisting> </informalexample> ! <para> ! This creates an object $cart of the class Cart. The function ! add_item() of that object is being called to add 1 item of article ! number 10 to the cart. ! </para><para> ! Classes can be extensions of other classes. The extended or ! derived class has all variables and functions of the base class ! and what you add in the extended defintion. This is done using ! the extends keyword. ! </para> <informalexample> ! <programlisting role=php> class Named_Cart extends Cart { var $owner; *************** *** 838,860 **** </programlisting> </informalexample> ! This defines a class Named_Cart that has all variables and functions of Cart plus an additional ! variable $owner and an additional function set_owner(). You create a named cart the usual way ! and can now set and get the carts owner. You can still use normal cart functions on named carts: <informalexample> ! <programlisting> $ncart = new Named_Cart; // Create a named cart $ncart->set_owner("kris"); // Name that cart print $ncart->owner; // print the cart owners name $ncart->add_item("10", 1); // (inherited functionality from cart) - </informalexample> </programlisting> ! Within functions of a class the variable $this means this object. You have to use $this->something ! to access any variable or function named something within your current object. ! ! </simpara> <!-- Keep this comment at the end of the file Local variables: --- 850,878 ---- </programlisting> </informalexample> ! <para> ! This defines a class Named_Cart that has all variables and ! functions of Cart plus an additional variable $owner and an ! additional function set_owner(). You create a named cart the usual ! way and can now set and get the carts owner. You can still use ! normal cart functions on named carts: ! </para> <informalexample> ! <programlisting role=php> $ncart = new Named_Cart; // Create a named cart $ncart->set_owner("kris"); // Name that cart print $ncart->owner; // print the cart owners name $ncart->add_item("10", 1); // (inherited functionality from cart) </programlisting> + </informalexample> ! <para> ! Within functions of a class the variable $this means this ! object. You have to use $this->something to access any variable or ! function named something within your current object. ! </para> ! </sect1> <!-- Keep this comment at the end of the file Local variables:

« previous php.dev (#28) next »