[PHP-DOC] cvs: phpdoc /en/language oop.xml
vrana Thu Aug 16 08:42:11 2007 UTC Modified files: /phpdoc/en/language oop.xml Log: Explicitly define var (bug #42285) http://cvs.php.net/viewvc.cgi/phpdoc/en/language/oop.xml?r1=1.68r2=1.69diff_format=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.68 phpdoc/en/language/oop.xml:1.69 --- phpdoc/en/language/oop.xml:1.68 Wed Jun 20 22:24:12 2007 +++ phpdoc/en/language/oop.xml Thu Aug 16 08:42:11 2007 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.68 $ -- +!-- $Revision: 1.69 $ -- chapter xml:id=language.oop xmlns=http://docbook.org/ns/docbook; titleClasses and Objects (PHP 4)/title @@ -7,7 +7,9 @@ titleliteralclass/literal/title para A class is a collection of variables and functions working with -these variables. A class is defined using the following syntax: +these variables. Variables are defined by literalvar/literal and +functions by literalfunction/literal. A class is defined using the +following syntax: /para para informalexample
[PHP-DOC] cvs: phpdoc /en/language oop.xml /en/language/oop5 magic.xml
vrana Sat Mar 24 08:23:49 2007 UTC Modified files: /phpdoc/en/language oop.xml /phpdoc/en/language/oop5magic.xml Log: What if __sleep doesn't return anything, fix example (bug #40344) http://cvs.php.net/viewvc.cgi/phpdoc/en/language/oop.xml?r1=1.66r2=1.67diff_format=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.66 phpdoc/en/language/oop.xml:1.67 --- phpdoc/en/language/oop.xml:1.66 Thu Apr 27 07:29:20 2006 +++ phpdoc/en/language/oop.xml Sat Mar 24 08:23:48 2007 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.66 $ -- +!-- $Revision: 1.67 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -755,11 +755,12 @@ being run prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. + If the method doesn't return anything then null; is serialized and + E_NOTICE is issued. /para para - The intended use of literal__sleep/literal is to close any - database connections that object may have, committing pending + The intended use of literal__sleep/literal is to commit pending data or perform similar cleanup tasks. Also, the function is useful if you have very large objects which need not be saved completely. http://cvs.php.net/viewvc.cgi/phpdoc/en/language/oop5/magic.xml?r1=1.13r2=1.14diff_format=u Index: phpdoc/en/language/oop5/magic.xml diff -u phpdoc/en/language/oop5/magic.xml:1.13 phpdoc/en/language/oop5/magic.xml:1.14 --- phpdoc/en/language/oop5/magic.xml:1.13 Sat Aug 12 16:09:29 2006 +++ phpdoc/en/language/oop5/magic.xml Sat Mar 24 08:23:49 2007 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.13 $ -- +!-- $Revision: 1.14 $ -- sect1 id=language.oop5.magic titleMagic Methods/title para @@ -41,15 +41,20 @@ executed prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. +If the method doesn't return anything then null; is serialized and +E_NOTICE is issued. /para para -The intended use of literal__sleep/literal is to close any -database connections that the object may have, commit pending +The intended use of literal__sleep/literal is to commit pending data or perform similar cleanup tasks. Also, the function is useful if you have very large objects which do not need to be saved completely. /para para +The literal__sleep/literal method should return the value to serialize +(usually literal$this/literal), otherwise null; is serialized. + /para + para Conversely, functionunserialize/function checks for the presence of a function with the magic name literal__wakeup/literal. If present, this function can @@ -87,7 +92,7 @@ public function __sleep() { -mysql_close($this-link); +return array('server', 'username', 'password', 'db'); } public function __wakeup()
[PHP-DOC] cvs: phpdoc /en/language oop.xml
vrana Thu Apr 27 07:25:56 2006 UTC Modified files: /phpdoc/en/language oop.xml Log: Grammar (bug #37216) http://cvs.php.net/viewcvs.cgi/phpdoc/en/language/oop.xml?r1=1.64r2=1.65diff_format=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.64 phpdoc/en/language/oop.xml:1.65 --- phpdoc/en/language/oop.xml:1.64 Fri Jul 22 12:27:17 2005 +++ phpdoc/en/language/oop.xml Thu Apr 27 07:25:56 2006 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.64 $ -- +!-- $Revision: 1.65 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -394,7 +394,7 @@ called when you create a new instance of a class with literalnew/literal. A function becomes a constructor, when it has the same name as the class. If a class -has no constructor, the constructor of the base class is being +has no constructor, the constructor of the base class will be called, if it exists. /para
[PHP-DOC] cvs: phpdoc /en/language oop.xml
vrana Thu Apr 27 07:29:20 2006 UTC Modified files: /phpdoc/en/language oop.xml Log: Grammar (bug #37215) http://cvs.php.net/viewcvs.cgi/phpdoc/en/language/oop.xml?r1=1.65r2=1.66diff_format=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.65 phpdoc/en/language/oop.xml:1.66 --- phpdoc/en/language/oop.xml:1.65 Thu Apr 27 07:25:56 2006 +++ phpdoc/en/language/oop.xml Thu Apr 27 07:29:20 2006 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.65 $ -- +!-- $Revision: 1.66 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -231,10 +231,11 @@ para Within a class definition, you do not know under which name the object will be accessible in your program: at the time the Cart class was -written, it was unknown that the object will be named -varname$cart/varname or varname$another_cart/varname later. Thus, +written, it was unknown whether the object would be named +varname$cart/varname, varname$another_cart/varname, or something +else later. Thus, you cannot write varname$cart-gt;items/varname within the Cart class -itself. Instead, in order to be able to access it's own functions and +itself. Instead, in order to be able to access its own functions and variables from within a class, one can use the pseudo-variable varname$this/varname which can be read as 'my own' or 'current object'. Thus, 'varname$this-gt;items[$artnr]/varname +=
[PHP-DOC] cvs: phpdoc /en/language oop.xml
vrana Fri Jul 22 08:27:18 2005 EDT Modified files: /phpdoc/en/language oop.xml Log: Serializing information is valid for PHP 5 too (bug #33817) http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.63r2=1.64ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.63 phpdoc/en/language/oop.xml:1.64 --- phpdoc/en/language/oop.xml:1.63 Tue Jul 12 18:09:57 2005 +++ phpdoc/en/language/oop.xml Fri Jul 22 08:27:17 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.63 $ -- +!-- $Revision: 1.64 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -651,7 +651,7 @@ caution simpara -The following information is valid for PHP 4 only. +The following information is valid for PHP gt;= 4 only. /simpara /caution
[PHP-DOC] cvs: phpdoc /en/language oop.xml
kennyt Tue Jul 12 18:09:59 2005 EDT Modified files: /phpdoc/en/language oop.xml Log: s/may no use/may not use/ #bug 33670 http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.62r2=1.63ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.62 phpdoc/en/language/oop.xml:1.63 --- phpdoc/en/language/oop.xml:1.62 Wed Apr 6 05:10:49 2005 +++ phpdoc/en/language/oop.xml Tue Jul 12 18:09:57 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.62 $ -- +!-- $Revision: 1.63 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -565,7 +565,7 @@ There are class functions, but there are no class variables. In fact, there is no object at all at the time of the call. Thus, a class function may not use any object variables (but -it can use local and global variables), and it may no use +it can use local and global variables), and it may not use varname$this/varname at all. /para
[PHP-DOC] cvs: phpdoc /en/language oop.xml
vrana Wed Apr 6 05:10:50 2005 EDT Modified files: /phpdoc/en/language oop.xml Log: Constructors - remove PHP 3 stuff, fix description of constructors inherited from parent class (bug #22253) http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.61r2=1.62ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.61 phpdoc/en/language/oop.xml:1.62 --- phpdoc/en/language/oop.xml:1.61 Wed Mar 9 06:40:59 2005 +++ phpdoc/en/language/oop.xml Wed Apr 6 05:10:49 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.61 $ -- +!-- $Revision: 1.62 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -389,28 +389,19 @@ sect1 id=language.oop.constructor titleConstructors/title - caution -simpara - In PHP 3 and PHP 4 constructors behave differently. The PHP 4 - semantics are strongly preferred. -/simpara - /caution - para Constructors are functions in a class that are automatically called when you create a new instance of a class with -literalnew/literal. In PHP 3, a -function becomes a constructor when it has the same name as -the class. In PHP 4, a function becomes a constructor, when -it has the same name as the class it is defined in - the -difference is subtle, but crucial (see below). +literalnew/literal. A function becomes a constructor, when +it has the same name as the class. If a class +has no constructor, the constructor of the base class is being +called, if it exists. /para informalexample programlisting role=php ![CDATA[ ?php -// Works in PHP 3 and PHP 4. class Auto_Cart extends Cart { function Auto_Cart() { $this-add_item(10, 1); @@ -435,7 +426,6 @@ programlisting role=php ![CDATA[ ?php -// Works in PHP 3 and PHP 4. class Constructor_Cart extends Cart { function Constructor_Cart($item = 10, $num = 1) { $this-add_item ($item, $num); @@ -443,11 +433,9 @@ } // Shop the same old boring stuff. - $default_cart = new Constructor_Cart; // Shop for real... - $different_cart = new Constructor_Cart(20, 17); ? ]] @@ -460,51 +448,6 @@ literal@new/literal. /para - caution -simpara - In PHP 3, derived classes and constructors have a number of - limitations. The following examples should be read carefully - to understand these limitations. -/simpara - /caution - - informalexample -programlisting role=php -![CDATA[ -?php -class A { -function A() { - echo I am the constructor of A.br /\n; -} -} - -class B extends A { -function C() { -echo I am a regular function.br /\n; -} -} - -// no constructor is being called in PHP 3. -$b = new B; -? -]] -/programlisting - /informalexample - - para -In PHP 3, no constructor is being called in the above example. -The rule in PHP 3 is: 'A constructor is a function of the same -name as the class.'. The name of the class is B, and there is -no function called B() in class B. Nothing happens. - /para - - para -This is fixed in PHP 4 by introducing another rule: If a class -has no constructor, the constructor of the base class is being -called, if it exists. The above example would have printed -'I am the constructor of A.lt;br /gt;' in PHP 4. - /para - informalexample programlisting role=php ![CDATA[ @@ -525,13 +468,9 @@ class B extends A { -function C() -{ -echo I am a regular function.br /\n; -} } -// This will call B() as a constructor. +// This will call B() as a constructor $b = new B; ? ]] @@ -539,43 +478,27 @@ /informalexample para -In PHP 3, the function B() in class A will suddenly become a +The function B() in class A will suddenly become a constructor in class B, although it was never intended to be. -The rule in PHP 3 is: 'A constructor is a function of the same -name as the class.'. PHP 3 does not care if the function is +PHP 4 does not care if the function is being defined in class B, or if it has been inherited. /para - para -This is fixed in PHP 4 by modifying the rule to: 'A constructor -is a function of the same name as the class it is being defined -in.'. Thus in PHP 4, the class B would have no constructor function -of its own and the constructor of the base class would have been -called, printing 'I am the constructor of A.lt;br /gt;'. - /para - caution simpara - Neither PHP 3 nor PHP 4 call constructors of the base class + PHP 4 doesn't call constructors of the base class automatically from a constructor of a derived class. It is your responsibility to propagate the call to constructors upstream where appropriate. /simpara /caution - note -simpara - There are no destructors in PHP 3 or PHP 4. You may use -
Re: [PHP-DOC] cvs: phpdoc /en/language oop.xml
On Wed, 6 Apr 2005, Jakub Vrana wrote: vrana Wed Apr 6 05:10:50 2005 EDT Modified files: /phpdoc/en/language oop.xml Log: Constructors - remove PHP 3 stuff, fix description of constructors inherited from parent class (bug #22253) Why did you remove PHP 3 stuff? Derick -- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org
Re: [PHP-DOC] cvs: phpdoc /en/language oop.xml
Derick Rethans wrote: Why did you remove PHP 3 stuff? sniper said it in http://bugs.php.net/bug.php?id=22253 . PHP 3 is old and behaves nearly same as PHP 4 in constructors. Jakub Vrana
[PHP-DOC] cvs: phpdoc /en/language oop.xml
damsWed Mar 9 06:41:01 2005 EDT Modified files: /phpdoc/en/language oop.xml Log: fixing bug 32247 http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.60r2=1.61ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.60 phpdoc/en/language/oop.xml:1.61 --- phpdoc/en/language/oop.xml:1.60 Mon Feb 14 04:10:10 2005 +++ phpdoc/en/language/oop.xml Wed Mar 9 06:40:59 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.60 $ -- +!-- $Revision: 1.61 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -101,7 +101,7 @@ caution simpara - The name literalstdClass/literal is used interally by + The name literalstdClass/literal is used internally by Zend and is reserved. You cannot have a class named literalstdClass/literal in PHP. /simpara @@ -196,13 +196,13 @@ functions add_item(), remove_item() and a variable items. These are distinct functions and variables. You can think of the objects as something similar to directories in a filesystem. In a filesystem you can -have two different files filenameREADME.TXT/filename, as long as they are in different -directories. Just like with directories where you'll have to type the -full pathname in order to reach each file from the toplevel directory, you -have to specify the complete name of the function you want to call: In PHP -terms, the toplevel directory would be the global namespace, and the -pathname separator would be literal-gt;/literal. Thus, the names -varname$cart-gt;items/varname and +have two different files filenameREADME.TXT/filename, as long as they +are in different directories. Just like with directories where you'll have +to type the full pathname in order to reach each file from the toplevel +directory, you have to specify the complete name of the function you want to +call: in PHP terms, the toplevel directory would be the global namespace, +and the pathname separator would be literal-gt;/literal. Thus, the +names varname$cart-gt;items/varname and varname$another_cart-gt;items/varname name two different variables. Note that the variable is named varname$cart-gt;items/varname, not varname$cart-gt;$items/varname, that is, a variable name in PHP has @@ -1133,8 +1133,8 @@ /screen /example Which is the output we will expect to obtain given the comparison rules - above. Only instances with the same values for their attributes and from the same - class are considered equal and identical. + above. Only instances with the same values for their attributes + and from the same class are considered equal and identical. /para para Even in the cases where we have object composition, the same comparison
[PHP-DOC] cvs: phpdoc /en/language oop.xml
vrana Mon Feb 14 04:10:13 2005 EDT Modified files: /phpdoc/en/language oop.xml Log: Constructors title is not literal http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.59r2=1.60ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.59 phpdoc/en/language/oop.xml:1.60 --- phpdoc/en/language/oop.xml:1.59 Mon Feb 7 21:51:45 2005 +++ phpdoc/en/language/oop.xml Mon Feb 14 04:10:10 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.59 $ -- +!-- $Revision: 1.60 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -387,7 +387,7 @@ /sect1 sect1 id=language.oop.constructor - titleliteralConstructors/literal/title + titleConstructors/title caution simpara
[PHP-DOC] cvs: phpdoc /en/language oop.xml
seanMon Feb 7 21:51:47 2005 EDT Modified files: /phpdoc/en/language oop.xml Log: slightly better wording http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.58r2=1.59ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.58 phpdoc/en/language/oop.xml:1.59 --- phpdoc/en/language/oop.xml:1.58 Sat Jan 29 01:19:14 2005 +++ phpdoc/en/language/oop.xml Mon Feb 7 21:51:45 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.58 $ -- +!-- $Revision: 1.59 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -249,7 +249,7 @@ The varname$this/varname pseudo-variable is not usually defined if the method in which it is hosted is called statically. This is not, however, a strict rule: varname$this/varname is defined if a method is - called statically from within another object, and the value of + called statically from within another object. In this case, the value of varname$this/varname is that of the calling object. This is illustrated in the following example: informalexample
[PHP-DOC] cvs: phpdoc /en/language oop.xml
seanSat Jan 29 01:19:15 2005 EDT Modified files: /phpdoc/en/language oop.xml Log: document seemingly-odd $this behaviour http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.57r2=1.58ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.57 phpdoc/en/language/oop.xml:1.58 --- phpdoc/en/language/oop.xml:1.57 Sun Jan 23 15:04:35 2005 +++ phpdoc/en/language/oop.xml Sat Jan 29 01:19:14 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.57 $ -- +!-- $Revision: 1.58 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -246,6 +246,62 @@ note para + The varname$this/varname pseudo-variable is not usually defined if + the method in which it is hosted is called statically. This is not, + however, a strict rule: varname$this/varname is defined if a method is + called statically from within another object, and the value of + varname$this/varname is that of the calling object. This is + illustrated in the following example: + informalexample + programlisting role=php +![CDATA[ +?php +class A +{ +function foo() +{ +if (isset($this)) { +echo '$this is defined ('; +echo get_class($this); +echo )\n; +} else { +echo \$this is not defined.\n; +} +} +} + +class B +{ +function bar() +{ +A::foo(); +} +} + +$a = new A(); +$a-foo(); +A::foo(); +$b = new B(); +$b-bar(); +B::bar(); +? +]] + /programlisting + example.outputs; + screen +![CDATA[ +$this is defined (a) +$this is not defined. +$this is defined (b) +$this is not defined. +]] + /screen + /informalexample +/para + /note + + note +para There are some nice functions to handle classes and objects. You might want to take a look at the link linkend=ref.classobjClass/Object Functions/link.
[PHP-DOC] cvs: phpdoc /en/language oop.xml
nlopess Wed Dec 8 06:59:36 2004 EDT Modified files: /phpdoc/en/language oop.xml Log: fix #31008: first example had a little bug http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.55r2=1.56ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.55 phpdoc/en/language/oop.xml:1.56 --- phpdoc/en/language/oop.xml:1.55 Tue Dec 7 14:28:42 2004 +++ phpdoc/en/language/oop.xml Wed Dec 8 06:59:35 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.55 $ -- +!-- $Revision: 1.56 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -16,22 +16,25 @@ ?php class Cart { var $items; // Items in our shopping cart - + // Add $num articles of $artnr to the cart - + function add_item($artnr, $num) { $this-items[$artnr] += $num; } - + // Take $num articles of $artnr out of the cart - + function remove_item($artnr, $num) { if ($this-items[$artnr] $num) { $this-items[$artnr] -= $num; return true; +} elseif ($this-items[$artnr] == $num) { +unset($this-items[$artnr]); +return true; } else { return false; -} +} } } ?
[PHP-DOC] cvs: phpdoc /en/language oop.xml
seanTue Dec 7 14:28:42 2004 EDT Modified files: /phpdoc/en/language oop.xml Log: elaborated on when a class may be 'broken' http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.54r2=1.55ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.54 phpdoc/en/language/oop.xml:1.55 --- phpdoc/en/language/oop.xml:1.54 Thu Sep 16 04:28:23 2004 +++ phpdoc/en/language/oop.xml Tue Dec 7 14:28:42 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.54 $ -- +!-- $Revision: 1.55 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -49,7 +49,9 @@ warning simpara You can emphasisNOT/emphasis break up a class definition into - multiple files, or multiple PHP blocks. The following will not work: + multiple files. You also can emphasisNOT/emphasis break a class + definition into multiple PHP blocks, unless the break is within a method + declaration. The following will not work: /simpara para informalexample @@ -68,6 +70,26 @@ /programlisting /informalexample /para +simpara + However, the following is allowed: +/simpara +para + informalexample + programlisting role=php +![CDATA[ +?php +class test { +function test() { +? +?php +print 'OK'; +} +} +? +]] + /programlisting + /informalexample +/para /warning simpara
[PHP-DOC] cvs: phpdoc /en/language oop.xml
vrana Thu Sep 16 04:28:24 2004 EDT Modified files: /phpdoc/en/language oop.xml Log: Name for paamayim-nekudotayim http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.53r2=1.54ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.53 phpdoc/en/language/oop.xml:1.54 --- phpdoc/en/language/oop.xml:1.53 Sun Jul 11 05:32:52 2004 +++ phpdoc/en/language/oop.xml Thu Sep 16 04:28:23 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.53 $ -- +!-- $Revision: 1.54 $ -- chapter id=language.oop titleClasses and Objects (PHP 4)/title @@ -499,7 +499,7 @@ /sect1 sect1 id=keyword.paamayim-nekudotayim!-- :-) -- - titleliteral::/literal/title + titleScope Resolution Operator (literal::/literal)/title caution simpara
[PHP-DOC] cvs: phpdoc /en/language oop.xml oop5.xml /en/language/oop5 oop5-decon.xml oop5-object-comparison.xml oop5-paamayim-nekudotayim.php oop5-paamayim-nekudotayim.xml
nlopess Sun Jul 11 05:32:52 2004 EDT Added files: /phpdoc/en/language/oop5oop5-object-comparison.xml oop5-paamayim-nekudotayim.xml Removed files: /phpdoc/en/language/oop5oop5-paamayim-nekudotayim.php Modified files: /phpdoc/en/language oop.xml oop5.xml /phpdoc/en/language/oop5oop5-decon.xml Log: fix :: move comparing objects in PHP 5 to oop5 http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.52r2=1.53ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.52 phpdoc/en/language/oop.xml:1.53 --- phpdoc/en/language/oop.xml:1.52 Sun May 23 12:02:56 2004 +++ phpdoc/en/language/oop.xml Sun Jul 11 05:32:52 2004 @@ -1,7 +1,7 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.52 $ -- +!-- $Revision: 1.53 $ -- chapter id=language.oop - titleClasses and Objects/title + titleClasses and Objects (PHP 4)/title sect1 id=keyword.class titleliteralclass/literal/title @@ -964,8 +964,8 @@ /para /sect1 - sect1 id=language.oop.object-comparison-php4 - titleComparing objects in PHP 4/title + sect1 id=language.oop.object-comparison + titleComparing objects/title para In PHP 4, objects are compared in a very simple manner, namely: Two object instances are equal if they have the same attributes and values, and are @@ -1114,103 +1114,6 @@ /screen /para /sect1 - - sect1 id=language.oop.object-comparison-php5 - titleComparing objects in PHP 5/title - warn.experimental; - para -In PHP 5, object comparison is a more complicated than in PHP 4 and more -in accordance to what one will expect from an Object Oriented Language -(not that PHP 5 is such a language). - /para - para -When using the comparison operator (literal==/literal), -object variables are compared in a simple manner, namely: Two object -instances are equal if they have the same attributes and values, and are -instances of the same class. - /para - para -On the other hand, when using the identity operator (literal===/literal), -object variables are identical if and only if they refer to the same -instance of the same class. - /para - para -An example will clarify these rules. -example - titleExample of object comparison in PHP 5/title - programlisting role='php' -![CDATA[ -?php -function bool2str($bool) { -if ($bool === false) { -return 'FALSE'; -} else { -return 'TRUE'; -} -} - -function compareObjects($o1, $o2) { -echo 'o1 == o2 : '.bool2str($o1 == $o2).\n; -echo 'o1 != o2 : '.bool2str($o1 != $o2).\n; -echo 'o1 === o2 : '.bool2str($o1 === $o2).\n; -echo 'o1 !== o2 : '.bool2str($o1 !== $o2).\n; -} - -class Flag { -var $flag; - -function Flag($flag=true) { -$this-flag = $flag; -} -} - -class OtherFlag { -var $flag; - -function OtherFlag($flag=true) { -$this-flag = $flag; -} -} - -$o = new Flag(); -$p = new Flag(); -$q = $o; -$r = new OtherFlag(); - -echo Two instances of the same class\n; -compareObjects($o, $p); - -echo \nTwo references to the same instance\n; -compareObjects($o, $q); - -echo \nInstances of two different classes\n; -compareObjects($o, $r); -? -]] - /programlisting -/example -This example will output: -screen -Two instances of the same class -o1 == o2 : TRUE -o1 != o2 : FALSE -o1 === o2 : FALSE -o1 !== o2 : TRUE - -Two references to the same instance -o1 == o2 : TRUE -o1 != o2 : FALSE -o1 === o2 : TRUE -o1 !== o2 : FALSE - -Instances of two different classes -o1 == o2 : FALSE -o1 != o2 : TRUE -o1 === o2 : FALSE -o1 !== o2 : TRUE -/screen - /para - /sect1 /chapter !-- Keep this comment at the end of the file http://cvs.php.net/diff.php/phpdoc/en/language/oop5.xml?r1=1.2r2=1.3ty=u Index: phpdoc/en/language/oop5.xml diff -u phpdoc/en/language/oop5.xml:1.2 phpdoc/en/language/oop5.xml:1.3 --- phpdoc/en/language/oop5.xml:1.2 Sat Jul 10 15:35:25 2004 +++ phpdoc/en/language/oop5.xml Sun Jul 11 05:32:52 2004 @@ -1,7 +1,7 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.2 $ -- +!-- $Revision: 1.3 $ -- chapter id=language.oop5 - titleClasses and Objects/title + titleClasses and Objects (PHP 5)/title sect1 id=op5.intro titleIntroduction/title @@ -12,10 +12,7 @@ language.oop5.oop5-decon; language.oop5.oop5-visibility; - !-- - Cant get this to show up right -language.oop5.oop5-paamayim-nekudotayim; - -- + language.oop5.oop5-paamayim-nekudotayim; language.oop5.oop5-static; language.oop5.oop5-constants; language.oop5.oop5-abstract; @@ -25,6 +22,7 @@ language.oop5.oop5-magic; language.oop5.oop5-final; language.oop5.oop5-cloning; + language.oop5.object-comparison; language.oop5.oop5-reflection; /chapter
[PHP-DOC] cvs: phpdoc /en/language oop.xml
vrana Sun May 23 12:02:56 2004 EDT Modified files: /phpdoc/en/language oop.xml Log: Typo http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.51r2=1.52ty=u Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.51 phpdoc/en/language/oop.xml:1.52 --- phpdoc/en/language/oop.xml:1.51 Wed May 5 16:19:50 2004 +++ phpdoc/en/language/oop.xml Sun May 23 12:02:56 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.51 $ -- +!-- $Revision: 1.52 $ -- chapter id=language.oop titleClasses and Objects/title @@ -241,7 +241,7 @@ has all variables and functions of the base class (this is called 'inheritance' despite the fact that nobody died) and what you add in the extended definition. It is not possible to -substract from a class, that is, to undefine any existing +subtract from a class, that is, to undefine any existing functions or variables. An extended class is always dependent on a single base class, that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'.
[PHP-DOC] cvs: phpdoc /en/language oop.xml
et Sun Dec 21 10:59:19 2003 EDT Modified files: /phpdoc/en/language oop.xml Log: Fix Bug #26402 Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.47 phpdoc/en/language/oop.xml:1.48 --- phpdoc/en/language/oop.xml:1.47 Fri Dec 12 14:56:00 2003 +++ phpdoc/en/language/oop.xml Sun Dec 21 10:59:19 2003 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.47 $ -- +!-- $Revision: 1.48 $ -- chapter id=language.oop titleClasses and Objects/title @@ -114,12 +114,13 @@ programlisting role=php ![CDATA[ ?php -/* None of these will work in PHP 4. */ class Cart { +/* None of these will work in PHP 4. */ var $todays_date = date(Y-m-d); var $name = $firstname; var $owner = 'Fred ' . 'Jones'; +/* Arrays containing constant values will, though. */ var $items = array(VCR, TV); } @@ -129,7 +130,7 @@ var $todays_date; var $name; var $owner; -var $items; +var $items = array(VCR, TV); function Cart() {
[PHP-DOC] cvs: phpdoc /en/language oop.xml
derick Wed Jun 18 06:55:03 2003 EDT Modified files: /phpdoc/en/language oop.xml Log: - Clarification of syntax and some structuring Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.42 phpdoc/en/language/oop.xml:1.43 --- phpdoc/en/language/oop.xml:1.42 Fri Jun 13 07:24:29 2003 +++ phpdoc/en/language/oop.xml Wed Jun 18 06:55:03 2003 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.42 $ -- +!-- $Revision: 1.43 $ -- chapter id=language.oop titleClasses and Objects/title @@ -8,7 +8,8 @@ para A class is a collection of variables and functions working with these variables. A class is defined using the following syntax: - + /para + para informalexample programlisting role=php ![CDATA[ @@ -48,17 +49,43 @@ items from this cart. /para - caution + warning simpara - The following cautionary notes are valid for PHP 4. + You can emphasisNOT/emphasis break up a class definition into + multiple files, or multiple PHP blocks. The following will not work: /simpara +para + informalexample + programlisting +![CDATA[ +?php +class test { +? +?php +function test() { +print 'OK'; +} +} +? +]] + /programlisting + /informalexample +/para + /warning + + simpara +The following cautionary notes are valid for PHP 4. + /simpara + caution simpara The name literalstdClass/literal is used interally by Zend and is reserved. You cannot have a class named literalstdClass/literal in PHP. /simpara + /caution + caution simpara The function names literal__sleep/literal and literal__wakeup/literal are magical in PHP classes. You @@ -66,7 +93,9 @@ classes unless you want the magic functionality associated with them. See below for more information. /simpara + /caution + caution simpara PHP reserves all function names starting with __ as magical. It is recommended that you do not use function names with @@ -74,16 +103,15 @@ /simpara /caution - note -simpara - In PHP 4, only constant initializers for literalvar/literal - variables are allowed. To initialize variables with non-constant - values, you need an initialization function which is called - automatically when an object is being constructed from the - class. Such a function is called a constructor (see below). -/simpara -informalexample - programlisting role=php + simpara +In PHP 4, only constant initializers for literalvar/literal +variables are allowed. To initialize variables with non-constant +values, you need an initialization function which is called +automatically when an object is being constructed from the +class. Such a function is called a constructor (see below). + /simpara + informalexample +programlisting role=php ![CDATA[ ?php /* None of these will work in PHP 4. */ @@ -112,9 +140,8 @@ } ? ]] - /programlisting -/informalexample - /note +/programlisting + /informalexample para Classes are types, that is, they are blueprints for actual @@ -137,29 +164,29 @@ /informalexample para -This creates the objects $cart and $another_cart, both of -the class Cart. The function add_item() of the $cart object -is being called to add 1 item of article number 10 to the -$cart. 3 items of article number 0815 are being added to -$another_cart. +This creates the objects varname$cart/varname and +varname$another_cart/varname, both of the class Cart. The function +add_item() of the varname$cart/varname object is being called to add 1 +item of article number 10 to the varname$cart/varname. 3 items of +article number 0815 are being added to varname$another_cart/varname. /para para -Both, $cart and $another_cart, have functions add_item(), -remove_item() and a variable items. These are distinct -functions and variables. You can think of the objects as -something similar to directories in a filesystem. In a -filesystem you can have two different files README.TXT, as -long as they are in different directories. Just like with -directories where you'll have to type the full pathname in -order to reach each file from the toplevel directory, you -have to specify the complete name of the function you want -to call: In PHP terms, the toplevel directory would be the -global namespace, and the pathname separator would be -gt;. -Thus, the names $cart-gt;items and $another_cart-gt;items -name two different variables. Note that the variable is -named $cart-gt;items, not $cart-gt;$items, that is, a -variable name in PHP has only a single dollar sign. +Both, varname$cart/varname and varname$another_cart/varname, have +functions add_item(), remove_item()
[PHP-DOC] cvs: phpdoc /en/language oop.xml
derick Fri Jun 13 07:24:29 2003 EDT Modified files: /phpdoc/en/language oop.xml Log: - PHP 5 has this too Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.41 phpdoc/en/language/oop.xml:1.42 --- phpdoc/en/language/oop.xml:1.41 Mon Jun 9 15:28:28 2003 +++ phpdoc/en/language/oop.xml Fri Jun 13 07:24:29 2003 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.41 $ -- +!-- $Revision: 1.42 $ -- chapter id=language.oop titleClasses and Objects/title @@ -489,7 +489,7 @@ caution simpara - The following is valid for PHP 4 only. + The following is valid for PHP 4 and later only. /simpara /caution -- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DOC] cvs: phpdoc /en/language oop.xml
jmcastagnetto Sat Apr 5 05:03:45 2003 EDT Modified files: /phpdoc/en/language oop.xml Log: Changed element id for obj. comp. in PHP4 Added docs on object comparison in PHP5 Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.39 phpdoc/en/language/oop.xml:1.40 --- phpdoc/en/language/oop.xml:1.39 Wed Apr 2 01:44:47 2003 +++ phpdoc/en/language/oop.xml Sat Apr 5 05:03:45 2003 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.39 $ -- +!-- $Revision: 1.40 $ -- chapter id=language.oop titleClasses and Objects/title @@ -936,16 +936,14 @@ /para /sect1 - sect1 id=language.oop.object-comparison + sect1 id=language.oop.object-comparison-php4 titleComparing objects in PHP 4/title - para In PHP 4, objects are compared in a very simple manner, namely: Two object instances are equal if they have the same attributes and values, and are instances of the same class. Similar rules are applied when comparing two objects using the identity operator (literal===/literal). /para - para If we were to execute the code in the example below: example @@ -1084,6 +1082,105 @@ o1 !== o2 : TRUE /screen /para + /sect1 + + sect1 id=language.oop.object-comparison-php5 + titleComparing objects in PHP 5/title + warn.experimental; + para +In PHP 5, object comparison is a more complicated than in PHP 4 and more +in accordance to what one will expect from an Object Oriented Language +(not that PHP 5 is such a language). + /para + para +When using the comparison operator (literal==/literal), +object variables are compared in a simple manner, namely: Two object +instances are equal if they have the same attributes and values, and are +instances of the same class, defined in the same namespace. + /para + para +On the other hand, when using the identity operator (literal===/literal), +object variables are identical if and only if they refer to the same +instance of the same class (in a particular namespace). + /para + para +An example will clarify these rules. +example + titleExample of object comparison in PHP 5/title + programlisting role='php' +![CDATA[ +function bool2str($bool) { +if ($bool === false) { +return 'FALSE'; +} else { +return 'TRUE'; +} +} + +function compareObjects($o1, $o2) { +echo 'o1 == o2 : '.bool2str($o1 == $o2).\n; +echo 'o1 != o2 : '.bool2str($o1 != $o2).\n; +echo 'o1 === o2 : '.bool2str($o1 === $o2).\n; +echo 'o1 !== o2 : '.bool2str($o1 !== $o2).\n; +} + +class Flag { +var $flag; + +function Flag($flag=true) { +$this-flag = $flag; +} +} + +namespace Other { + +class Flag { +var $flag; + +function Flag($flag=true) { +$this-flag = $flag; +} +} + +} + +$o = new Flag(); +$p = new Flag(); +$q = $o; +$r = new Other::Flag(); + +echo Two instances of the same class\n; +compareObjects($o, $p); + +echo \nTwo references to the same instance\n; +compareObjects($o, $q); + +echo \nInstances of similarly named classes in different namespaces\n; +compareObjects($o, $r); +]] + /programlisting +/example +This example will output: +screen +Two instances of the same class +o1 == o2 : TRUE +o1 != o2 : FALSE +o1 === o2 : FALSE +o1 !== o2 : TRUE + +Two references to the same instance +o1 == o2 : TRUE +o1 != o2 : FALSE +o1 === o2 : TRUE +o1 !== o2 : FALSE + +Instances of similarly named classes in different namespaces +o1 == o2 : FALSE +o1 != o2 : TRUE +o1 === o2 : FALSE +o1 !== o2 : TRUE +/screen + /para /sect1 /chapter -- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DOC] cvs: phpdoc /en/language oop.xml
derick Wed Apr 2 01:44:47 2003 EDT Modified files: /phpdoc/en/language oop.xml Log: - Fix XML Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.38 phpdoc/en/language/oop.xml:1.39 --- phpdoc/en/language/oop.xml:1.38 Tue Apr 1 01:39:54 2003 +++ phpdoc/en/language/oop.xml Wed Apr 2 01:44:47 2003 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.38 $ -- +!-- $Revision: 1.39 $ -- chapter id=language.oop titleClasses and Objects/title @@ -1031,18 +1031,7 @@ Even in the cases where we have object composition, the same comparison rules apply. In the example below we create a container class that stores an associative array of classnameFlag/classname objects. - exampleComposite objects u(o,p) and v(q,p) -o1 == o2 : TRUE -o1 != o2 : FALSE -o1 === o2 : TRUE -o1 !== o2 : FALSE - -u(o,p) and w(q) -o1 == o2 : FALSE -o1 != o2 : TRUE -o1 === o2 : FALSE -o1 !== o2 : TRUE - + example titleCompound object comparisons in PHP 4/title programlisting role='php' ![CDATA[ -- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DOC] cvs: phpdoc /en/language oop.xml /en/reference/gmp/functions gmp-gcdext.xml /entities global.ent /images diophantine-equation.png
jmcastagnetto Tue Apr 1 01:39:54 2003 EDT Added files: /phpdoc/images diophantine-equation.png Modified files: /phpdoc/en/language oop.xml /phpdoc/en/reference/gmp/functions gmp-gcdext.xml /phpdoc/entitiesglobal.ent Log: Added some blurb on diophantine eqs to gmp_gcdext Added blurb on object comparisons in PHP4 Known bug: make html does not copy the PNG from images to the correct dir Someone with more insight on what to change in configure.in and related can do the changes (don't want to break the build). Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.37 phpdoc/en/language/oop.xml:1.38 --- phpdoc/en/language/oop.xml:1.37 Sun Sep 15 11:46:44 2002 +++ phpdoc/en/language/oop.xml Tue Apr 1 01:39:54 2003 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.37 $ -- +!-- $Revision: 1.38 $ -- chapter id=language.oop titleClasses and Objects/title @@ -774,7 +774,7 @@ { echo br,$this-name; } - + function setName($name) { $this-name = $name; @@ -935,6 +935,167 @@ /informalexample /para /sect1 + + sect1 id=language.oop.object-comparison + titleComparing objects in PHP 4/title + + para + In PHP 4, objects are compared in a very simple manner, namely: Two object + instances are equal if they have the same attributes and values, and are + instances of the same class. Similar rules are applied when comparing two + objects using the identity operator (literal===/literal). + /para + + para + If we were to execute the code in the example below: + example +titleExample of object comparison in PHP 4/title +programlisting role='php' +![CDATA[ +function bool2str($bool) { +if ($bool === false) { +return 'FALSE'; +} else { +return 'TRUE'; +} +} + +function compareObjects($o1, $o2) { +echo 'o1 == o2 : '.bool2str($o1 == $o2).\n; +echo 'o1 != o2 : '.bool2str($o1 != $o2).\n; +echo 'o1 === o2 : '.bool2str($o1 === $o2).\n; +echo 'o1 !== o2 : '.bool2str($o1 !== $o2).\n; +} + +class Flag { +var $flag; + +function Flag($flag=true) { +$this-flag = $flag; +} +} + +class SwitchableFlag extends Flag { + +function turnOn() { +$this-flag = true; +} + +function turnOff() { +$this-flag = false; +} +} + +$o = new Flag(); +$p = new Flag(false); +$q = new Flag(); + +$r = new SwitchableFlag(); + +echo Compare instances created with the same parameters\n; +compareObjects($o, $q); + +echo \nCompare instances created with different parameters\n; +compareObjects($o, $p); + +echo \nCompare an instance of a parent class with one from a subclass\n; +compareObjects($o, $r); +]] +/programlisting + /example + We will see: + screen +Compare instances created with the same parameters +o1 == o2 : TRUE +o1 != o2 : FALSE +o1 === o2 : TRUE +o1 !== o2 : FALSE + +Compare instances created with different parameters +o1 == o2 : FALSE +o1 != o2 : TRUE +o1 === o2 : FALSE +o1 !== o2 : TRUE + +Compare an instance of a parent class with one from a subclass +o1 == o2 : FALSE +o1 != o2 : TRUE +o1 === o2 : FALSE +o1 !== o2 : TRUE + /screen + Which is the output we will expect to obtain given the comparison rules + above. Only instances with the same values for their attributes and from the same + class are considered equal and identical. + /para + para + Even in the cases where we have object composition, the same comparison + rules apply. In the example below we create a container class that stores + an associative array of classnameFlag/classname objects. + exampleComposite objects u(o,p) and v(q,p) +o1 == o2 : TRUE +o1 != o2 : FALSE +o1 === o2 : TRUE +o1 !== o2 : FALSE + +u(o,p) and w(q) +o1 == o2 : FALSE +o1 != o2 : TRUE +o1 === o2 : FALSE +o1 !== o2 : TRUE + +titleCompound object comparisons in PHP 4/title +programlisting role='php' +![CDATA[ +class FlagSet { +var $set; + +function FlagSet($flagArr = array()) { +$this-set = $flagArr; +} + +function addFlag($name, $flag) { +$this-set[$name] = $flag; +} + +function removeFlag($name) { +if (array_key_exists($name, $this-set)) { +unset($this-set[$name]); +} +} +} + + +$u = new FlagSet(); +$u-addFlag('flag1', $o); +$u-addFlag('flag2', $p); +$v = new FlagSet(array('flag1'=$q, 'flag2'=$p)); +$w = new FlagSet(array('flag1'=$q)); + +echo \nComposite objects u(o,p) and v(q,p)\n; +compareObjects($u, $v); + +echo \nu(o,p) and w(q)\n; +compareObjects($u, $w); + +]] +/programlisting + /example + Which gives the expected output: + screen +Composite objects u(o,p) and v(q,p) +o1 == o2 : TRUE +o1 != o2 : FALSE +o1 === o2 : TRUE +o1 !== o2 : FALSE + +u(o,p) and w(q) +o1 == o2 : FALSE +o1 != o2 : TRUE +o1 === o2 : FALSE +o1 !== o2 : TRUE + /screen + /para + /sect1
[PHP-DOC] cvs: phpdoc /en/language oop.xml references.xml
mfischerMon Jun 10 06:51:59 2002 EDT Modified files: /phpdoc/en/language oop.xml references.xml Log: - Document that we have new but not new or new, closes #14094. Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.35 phpdoc/en/language/oop.xml:1.36 --- phpdoc/en/language/oop.xml:1.35 Mon Jun 10 04:43:11 2002 +++ phpdoc/en/language/oop.xml Mon Jun 10 06:51:57 2002 -1,5 +1,5 ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.35 $ -- +!-- $Revision: 1.36 $ -- chapter id=language.oop titleClasses and Objects/title -343,6 +343,12 ]] /programlisting /informalexample + + para +You also can use the literal/literal operator to +emphasismute/emphasis errors occuring in the constructor, e.g. +literalnew/literal. + /para caution simpara Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.22 phpdoc/en/language/references.xml:1.23 --- phpdoc/en/language/references.xml:1.22 Wed Dec 12 16:29:56 2001 +++ phpdoc/en/language/references.xml Mon Jun 10 06:51:58 2002 -1,5 +1,5 ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.22 $ -- +!-- $Revision: 1.23 $ -- chapter id=language.references titleReferences Explained/title -62,6 +62,13 literal$this/literal will operate on the copy, which is not always what is desired. Usually you want to have a single instance to work with, due to performance and memory consumption issues. + /para + para + While you can use the literal/literal operator to + emphasismute/emphasis any errors in the constructor when using it as + literalnew/literal, this does not work when using the + literalamp;new/literal statement. This is a limitation of the Zend + Engine and will therefore result in a parser error. /para /note para
[PHP-DOC] cvs: phpdoc-pl /language oop.xml
leszek Fri May 24 09:14:56 2002 EDT Modified files: /phpdoc-pl/language oop.xml Log: [leszek] Updated to 1.34 Index: phpdoc-pl/language/oop.xml diff -u phpdoc-pl/language/oop.xml:1.9 phpdoc-pl/language/oop.xml:1.10 --- phpdoc-pl/language/oop.xml:1.9 Sat Mar 30 18:10:38 2002 +++ phpdoc-pl/language/oop.xml Fri May 24 09:14:55 2002 -1,6 +1,6 ?xml version=1.0 encoding=iso-8859-2? !-- EN-Revision: 1.32 Maintainer: leszek Status: ready -- -!-- $Revision: 1.9 $ -- +!-- $Revision: 1.10 $ -- chapter id=language.oop titleKlasy i Obiekty/title -109,7 +109,8 $this-nazwa = $GLOBALS['imie']; /* itp. . . */ } -} +} +? ]] /programlisting /informalexample -183,6 +184,14 artykuly' lub 'dodaj $liczba do licznika $nrartz tablicy artykuly zawartej w bie¿±cym obiekcie'. /para + + note +para + Istnieje kilka przyjemnych funkcji do obs³ugi klas i obiektów. Mo¿esz je + zobaczyæ w rozdziale link linkend=ref.classobjFunkcje obs³ugi klas i + obiektów/link +/para +note /sect1 sect1 id=keyword.extends
[PHP-DOC] cvs: phpdoc-pl /language oop.xml
leszek Fri May 24 09:34:05 2002 EDT Modified files: /phpdoc-pl/language oop.xml Log: [leszek] Doh, forgot about revcheck Index: phpdoc-pl/language/oop.xml diff -u phpdoc-pl/language/oop.xml:1.10 phpdoc-pl/language/oop.xml:1.11 --- phpdoc-pl/language/oop.xml:1.10 Fri May 24 09:14:55 2002 +++ phpdoc-pl/language/oop.xml Fri May 24 09:34:05 2002 -1,6 +1,6 ?xml version=1.0 encoding=iso-8859-2? -!-- EN-Revision: 1.32 Maintainer: leszek Status: ready -- -!-- $Revision: 1.10 $ -- +!-- EN-Revision: 1.34 Maintainer: leszek Status: ready -- +!-- $Revision: 1.11 $ -- chapter id=language.oop titleKlasy i Obiekty/title
[PHP-DOC] cvs: phpdoc /en/language oop.xml
tom Wed May 15 16:41:17 2002 EDT Modified files: /phpdoc/en/language oop.xml Log: closed php-tag in example Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.33 phpdoc/en/language/oop.xml:1.34 --- phpdoc/en/language/oop.xml:1.33 Mon Apr 1 13:24:26 2002 +++ phpdoc/en/language/oop.xml Wed May 15 16:41:17 2002 -1,5 +1,5 ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.33 $ -- +!-- $Revision: 1.34 $ -- chapter id=language.oop titleClasses and Objects/title -110,6 +110,7 /* etc. . . */ } } +? ]] /programlisting /informalexample
[PHP-DOC] cvs: phpdoc-de /language oop.xml
tom Wed May 15 16:43:44 2002 EDT Modified files: /phpdoc-de/language oop.xml Log: sync to en, reworded sentence Index: phpdoc-de/language/oop.xml diff -u phpdoc-de/language/oop.xml:1.11 phpdoc-de/language/oop.xml:1.12 --- phpdoc-de/language/oop.xml:1.11 Tue May 7 08:18:08 2002 +++ phpdoc-de/language/oop.xml Wed May 15 16:43:44 2002 -1,5 +1,5 ?xml version=1.0 encoding=iso-8859-1? -!-- EN-Revision: 1.33 Maintainer: tom Status: working -- +!-- EN-Revision: 1.34 Maintainer: tom Status: working -- chapter id=language.oop titleKlassen und Objekte/title -69,7 +69,7 /simpara simpara - Sämtliche mit __ beginnende Funktionsnamen PHP als magisch + Sämtliche mit __ beginnende Funktionsnamen sind PHP als magisch vorbehalten. Es wird empfohlen, in PHP keine Funktionsnamen mit __ zu verwenden, außer Sie möchten dokumentierte magische Funktionalität. -113,6 +113,7 /* etc. . . */ } } +? ]] /programlisting /informalexample
[PHP-DOC] cvs: phpdoc-de /language oop.xml
tom Tue May 7 08:18:08 2002 EDT Modified files: /phpdoc-de/language oop.xml Log: finished translation Index: phpdoc-de/language/oop.xml diff -u phpdoc-de/language/oop.xml:1.10 phpdoc-de/language/oop.xml:1.11 --- phpdoc-de/language/oop.xml:1.10 Sun Apr 7 06:04:16 2002 +++ phpdoc-de/language/oop.xml Tue May 7 08:18:08 2002 -695,44 +695,44 /sect1 sect1 id=language.oop.magic-functions - titleThe magic functions literal__sleep/literal and literal__wakeup/literal/title + titleDie magischen Funktionen literal__sleep/literal und +literal__wakeup/literal/title para - functionserialize/function checks if your class has a function with - the magic name literal__sleep/literal. If so, that function is - being run prior to any serialization. It can clean up the object - and is supposed to return an array with the names of all variables - of that object that should be serialized. + functionserialize/function prüft, ob Ihre Klasse eine Funktion mit + dem magischen Namen literal__sleep/literal enthält. Wenn dem so ist, + wird diese Funktion vor einer Serialisierung ausgeführt. Sie kann das + Objekt aufräumen und soll ein Array mit den Namen aller Variablen des + zu serialisierenden Objektes zurückgeben. /para para - The intended use of literal__sleep/literal is to close any - database connections that object may have, committing pending - data or perform similar cleanup tasks. Also, the function is - useful if you have very large objects which need not be - saved completely. + Die beabsichtigte Verwendung von literal__sleep/literal ist, + eventuelle Datenbankverbindungen des Objektes zu schließen, noch + offene Daten zu committen, oder ähnliche Säuberungsaktionen + durchzuführen. Weiters ist diese Funktion hilfreich, wenn Sie + sehr große Objekte haben, die nicht komplett gespeichert werden + müssen. /para para - Conversely, functionunserialize/function checks for the - presence of a function with the magic name - literal__wakeup/literal. If present, this function can - reconstruct any resources that object may have. + Umgekehrt prüft functionunserialize/function die Existenz einer + Funktion mit dem magischen Namen literal__wakeup/literal. Ist + diese vorhanden, kann sie Ressourcen des Objektes rekonstruieren. /para para -The intended use of literal__wakeup/literal is to -reestablish any database connections that may have been lost -during serialization and perform other reinitialization -tasks. +Die vorgesehene Verwendung von literal__wakeup/literal ist die +Wiederherstellung von Datenbankverbindungen, welche während der +Serialisierung verloren gegangen sein könnten, sowie andere +Neuinitialisierungen. /para /sect1 sect1 id=language.oop.newref - titleReferences inside the constructor/title + titleReferenzen innherhalb des Konstruktors/title para -Creating references within the constructor can lead to confusing -results. This tutorial-like section helps you to avoid problems. +Referenzen innerhalb des Konstruktors können zu verwirrenden +Resultaten führen. Dieser Abschnitt hilft, Probleme zu vermeiden. informalexample programlisting role=php -741,12 +741,12 { function Foo($name) { -// create a reference inside the global array $globalref +// eine Referenz innerhalb des globalen Arrays $globalref erstellen global $globalref; $globalref[] = $this; -// set name to passed value +// setze den Namen auf den übergebenen Wert $this-setName($name); -// and put it out +// und gib' ihn aus $this-echoName(); } -766,11 +766,10 /para para -Let us check out if there is a difference between -varname$bar1/varname which has been created using -the copy literal=/literal operator and -varname$bar2/varname which has been created using -the reference literal=amp;/literal operator... +Prüfen wir, ob zwischen varname$bar1/varname, die mittels +dem Operator zum Kopieren literal=/literal erstellt wurde, +und varname$bar2/varname, die mittels dem Referenzoperator +literal=amp;/literal erstellt wurde, besteht... informalexample programlisting role=php -779,7 +778,7 $bar1-echoName(); $globalref[0]-echoName(); -/* output: +/* Ausgabe: set in constructor set in constructor set in constructor */ -788,7 +787,7 $bar2-echoName(); $globalref[1]-echoName(); -/* output: +/* Ausgabe: set in constructor set in constructor set in constructor */ -797,49 +796,50 /informalexample /para para -Apparently there is no difference, but in fact there is a -very significant one: varname$bar1/varname and -varname$globalref[0]/varname are _NOT_ referenced, they -are NOT the same variable. This is because new does not -
[PHP-DOC] cvs: phpdoc /it/language oop.xml
alan_dangeloWed May 1 08:15:13 2002 EDT Modified files: /phpdoc/it/language oop.xml Log: Update Translation to En-Revision 1.33 Index: phpdoc/it/language/oop.xml diff -u phpdoc/it/language/oop.xml:1.12 phpdoc/it/language/oop.xml:1.13 --- phpdoc/it/language/oop.xml:1.12 Sat Dec 22 16:32:04 2001 +++ phpdoc/it/language/oop.xml Wed May 1 08:15:13 2002 -1,5 +1,5 ?xml version=1.0 encoding=iso-8859-1? -!-- EN-Revision: 1.32 Maintainer: alan_dangelo Status: ready -- +!-- EN-Revision: 1.33 Maintainer: alan_dangelo Status: ready -- chapter id=language.oop titleClassi e Oggetti/title -76,11 +76,10 note simpara - In PHP 4, sono permesse inizializzazioni di variabili con valori - costanti solamente grazie all'uso di literalvar/literal. Per - inizializzare variabili con valori non-costanti, bisogna creare - una funzione d'inizializzazione che è chiamata automaticamente - all'istanziazione di un oggetto da una classe. Questo tipo di + In PHP 4, sono permesse inizializzazioni di variabili con valori costanti +solamente + grazie all'uso di literalvar/literal. Per inizializzare variabili con valori + non-costanti, bisogna creare una funzione d'inizializzazione che è chiamata + automaticamente all'istanziazione di un oggetto da una classe. Questo tipo di funzione si chiama costruttore (vedi sotto). /simpara informalexample -158,6 +157,7 e $another_cart-gt;items sono due diverse variabili che differiscono per il nome. Si noti che la variabile si chiama $cart-gt;items, e non $cart-gt;$items, questo perchè le variabili il PHP si scrivono con un unico simbolo di dollaro. + /para informalexample -188,7 +188,16 '$this-gt;items[$artnr] += $num' può essere letto come 'aggiungi $num al contatore $artnr al del mio array degli articoli' o 'aggiungi $num al contatore $artnr dell'array degli articoli di questo oggetto'. + /para + + note +para +Ci sono molte utili funzioni per manipolare classi ed oggetti. You might want +dare un'occhiata alle link linkend=ref.classobjClass/Object +Functions/link +/para + /note /sect1 sect1 id=keyword.extends -196,7 +205,7 para Spesso si ha bisogno di avere classi con variabili e funzioni -simili ad altre classi. É buona norma perciò definire una classe in modo +simili ad altre classi. É buona norma definire una classe in modo generico, sia per poterla riutilizzare spesso, sia per poterla adattare a scopi specifici.Per facilitare questa operazione, è possibile generare classi per estensione di altre classi. Una classe estesa o derivata -206,6 +215,8 variabili e funzioni di una classe madre. Una classe estesa dipende sempre da una singola classe di base: l'eredità multipla non è supportata. Le classi si estendono usando la parola chiave 'extends'. + + /para informalexample -281,15 +292,13 /informalexample para -Questo codice definisce una classe Auto_Cart che non è altro che +Questo codice definisce una classe Auto_Cart, che non è altro che Cart più un costruttore che inizializza il carrello con una occorrenza dell'articolo numero 10 ogni volta che un nuovo Auto_Cart è creato con -new. I costruttori possono avere degli argomenti, e questi argomenti -possono essere facoltativi, questo li rende molto versatili. Per -potere usare una classe senza specificare parametri (gli argomenti -richiesti dal costruttore), tutti i parametri del costruttore devono -essere resi facoltativi fornendo dei valori di default agli argomenti -della funzione. +new. I costruttori possono avere degli argomenti, e gli argomenti possono +essere facoltativi, questo li rende molto versatili. Per poter usare una classe +senza specificare parametri, tutti i parametri del costruttore devono essere resi +facoltativi con valori di default. /para informalexample -398,8 +407,7 improvvisamente in un costruttore per la classe B, anche se questo non era previsto. La regola in PHP 3 è: 'un costruttore è una funzione che ha lo stesso nome di una classe'. PHP 3 non -si preoccupa se la funzione è stata definita nella classe B o -se è stata ereditata. +si preoccupa se la funzione è stata definita nella classe B o se è stata +ereditata. /para para -448,6 +456,7 A volte è utile riferirsi alle funzioni ed alle variabili di classi base o riferirsi alle funzioni di classi senza istanziarle. L'operatore :: è usato per questi scopi. + /para informalexample -492,6 +501,7 si possa richiamare con $a-example(). example() è chiamata come 'funzione della classe', e non come funzione di un oggetto della classe. + /para para -509,6 +519,7 esplicitamente con l'operatore ::
[PHP-DOC] cvs: phpdoc /it/language oop.xml
alan_dangeloWed May 1 08:26:30 2002 EDT Modified files: /phpdoc/it/language oop.xml Log: One small correction Index: phpdoc/it/language/oop.xml diff -u phpdoc/it/language/oop.xml:1.13 phpdoc/it/language/oop.xml:1.14 --- phpdoc/it/language/oop.xml:1.13 Wed May 1 08:15:13 2002 +++ phpdoc/it/language/oop.xml Wed May 1 08:26:30 2002 -193,9 +193,9 note para -Ci sono molte utili funzioni per manipolare classi ed oggetti. You might want -dare un'occhiata alle link linkend=ref.classobjClass/Object -Functions/link +Ci sono molte utili funzioni per manipolare classi ed oggetti. Se +desiderate conoscerle potete dare un'occhiata alle +link linkend=ref.classobjClass/Object Functions/link /para /note /sect1
[PHP-DOC] cvs: phpdoc /hu/language oop.xml
gobaMon Apr 15 15:26:16 2002 EDT Modified files: /phpdoc/hu/language oop.xml Log: Getting in sync Index: phpdoc/hu/language/oop.xml diff -u phpdoc/hu/language/oop.xml:1.11 phpdoc/hu/language/oop.xml:1.12 --- phpdoc/hu/language/oop.xml:1.11 Tue Jan 29 13:06:24 2002 +++ phpdoc/hu/language/oop.xml Mon Apr 15 15:26:15 2002 -1,5 +1,5 ?xml version=1.0 encoding=iso-8859-2? -!-- EN-Revision: 1.32 Maintainer: goba Status: ready -- +!-- EN-Revision: 1.33 Maintainer: goba Status: ready -- !-- CREDITS: gerzson -- chapter id=language.oop -190,7 +190,14 olvasható, hogy 'adj $db darab $sorsz sorszámú terméket a saját dolgok tömbömhöz', vagy 'adj $db darab $sorsz sorszámú terméket az aktuális objektumpéldány dolgok tömbjéhez'. - /para + /para + note +para + Van pár hasznos függvény az osztályok és objektumok kezeléséhez. + Lásd az link linkend=ref.classobjOsztály és objektum + függvények/link címû részt. +/para + /note /sect1 sect1 id=keyword.extends
[PHP-DOC] cvs: phpdoc /de/language oop.xml
tom Sun Apr 7 06:04:16 2002 EDT Modified files: /phpdoc/de/language oop.xml Log: translated a bit more Index: phpdoc/de/language/oop.xml diff -u phpdoc/de/language/oop.xml:1.9 phpdoc/de/language/oop.xml:1.10 --- phpdoc/de/language/oop.xml:1.9 Thu Mar 28 15:44:54 2002 +++ phpdoc/de/language/oop.xml Sun Apr 7 06:04:16 2002 -1,5 +1,5 ?xml version=1.0 encoding=iso-8859-1? -!-- EN-Revision: 1.32 Maintainer: tom Status: working -- +!-- EN-Revision: 1.33 Maintainer: tom Status: working -- chapter id=language.oop titleKlassen und Objekte/title -81,7 +81,7 In PHP 4 sind nur konstante Initialisierungen für literalvar/literal Variablen erlaubt. Um Variablen mit nicht konstanten Werten zu initialisieren, benötigen Sie eine Funktion - zur Intitialisierung, welche beim Erstellen eines Objektes + zur Initialisierung, welche beim Erstellen eines Objektes automatisch von der Klasse aufgerufen wird. Eine solche Funktion wird Konstruktor genannt (siehe unten). /simpara -193,25 +193,32 zu $artnr in meinem eigenen Array items', oder 'addiere $num zu $artnr im Array items innerhalb des aktuellen Objektes' lesen. /para + + note +para +Es gibt ein paar angenehme Funktionen, um mit Klassen und Objekten umzugehen. +Mehr darüber erfahren Sie im Kapitel link linkend=ref.classobjKlassen- +und Objekt-Funktionen/link. +/para + /note /sect1 sect1 id=keyword.extends titleliteralextends/literal/title para -Often you need classes with similar variables and functions -to another existing class. In fact, it is good practice to -define a generic class which can be used in all your -projects and adapt this class for the needs of each of your -specific projects. To facilitate this, classes can be -extensions of other classes. The extended or derived class -has all variables and functions of the base class (this is -called 'inheritance' despite the fact that nobody died) and what -you add in the extended definition. It is not possible to -substract from a class, that is, to undefine any existing -functions or variables. An extended class is always dependent -on a single base class, that is, multiple inheritance is -not supported. Classes are extended using the keyword 'extends'. +Oft braucht man Klassen mit in einer anderen Klasse ähnlichen Variablen +und Funktionen. So ist es eine gute Vorgehensweise, eine in allen Ihren +Projekten verwendbare Oberklasse zu definieren, und diese dann den +Bedürfnissen Ihrer einzelnen Projekte anzupassen. Um dies zu erleichtern, +können Klassen andere Klassen erweitern. Die erweiterte bzw. abgeleitete +Klasse verfügt über alle Variablen und Funktionen der Basisklasse (dies +wird 'Vererbung' genannt, obwohl niemand gestorben ist), und was Sie in +der erweiterten Definition hinzufügen. Es ist nicht möglich, etwas von +einer Klasse wegzunehmen, d.h. Sie können keine existierenden Variablen +oder Funktionen 'wegdefinieren'. Eine Unterklasse ist immer von einer +einzigen Oberklasse abhängig, d.h. Mehrfachvererbung wird nicht +unterstützt. Klassen werden mittels dem Schlüsselwort 'extends' erweitert. /para informalexample -231,20 +238,21 /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: +Hier wird die Klasse Named_Cart definiert, die über alle Variablen +und Funktionen von Cart, plus der Variable $owner und der Funktion +set_owner() verfügt. Sie können einen bestimmten Einkaufswagen +(Named_Cart) auf dem üblichen Weg erstellen, und nun auch den +Besitzer (owner) bestimmen und erfragen. Sie können noch immer +die normalen Cart Funktionen an Named_Cart anwenden: /para informalexample programlisting role=php ![CDATA[ -$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) +$ncart = new Named_Cart;// Erstellt einen bestimmten Einkaufwagen +$ncart-set_owner(kris); // den Besitzer festlegen +print $ncart-owner;// den Besitzer ausgeben +$ncart-add_item(10, 1); // (vererbte Funktionalität von Cart) ]] /programlisting /informalexample -252,29 +260,30 /sect1 sect1 id=language.oop.constructor - titleliteralConstructors/literal/title + titleliteralKonstruktoren/literal/title caution simpara - In PHP 3 and PHP 4 constructors behave differently. The PHP 4 - semantics are strongly preferred. + In PHP 3 und
[PHP-DOC] cvs: phpdoc /en/language oop.xml
sander Mon Apr 1 13:24:26 2002 EDT Modified files: /phpdoc/en/language oop.xml Log: Added link from language.oop to ref.classobj. Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.32 phpdoc/en/language/oop.xml:1.33 --- phpdoc/en/language/oop.xml:1.32 Wed Dec 12 15:47:39 2001 +++ phpdoc/en/language/oop.xml Mon Apr 1 13:24:26 2002 -1,5 +1,5 ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.32 $ -- +!-- $Revision: 1.33 $ -- chapter id=language.oop titleClasses and Objects/title -190,6 +190,14 array' or 'add $num to the $artnr counter of the items array within the current object'. /para + + note +para +There are some nice functions to handle classes and objects. You might want +to take a look at the link linkend=ref.classobjClass/Object +Functions/link +/para + /note /sect1 sect1 id=keyword.extends
[PHP-DOC] cvs: phpdoc /de/language oop.xml
tom Thu Mar 28 15:44:54 2002 EDT Modified files: /phpdoc/de/language oop.xml Log: first part translated Index: phpdoc/de/language/oop.xml diff -u phpdoc/de/language/oop.xml:1.8 phpdoc/de/language/oop.xml:1.9 --- phpdoc/de/language/oop.xml:1.8 Wed Mar 27 14:22:06 2002 +++ phpdoc/de/language/oop.xml Thu Mar 28 15:44:54 2002 -1,30 +1,30 ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.8 $ -- +!-- EN-Revision: 1.32 Maintainer: tom Status: working -- chapter id=language.oop - titleClasses and Objects/title + titleKlassen und Objekte/title sect1 id=keyword.class - titleliteralclass/literal/title + titleliteralKlassen/literal/title para -A class is a collection of variables and functions working with -these variables. A class is defined using the following syntax: - +Eine Klasse ist eine Sammlung von Variablen und Funktionen, die +mit diesen Variablen arbeiten. Eine Klasse wird folgendermaßen +definiert: informalexample programlisting role=php ![CDATA[ ?php class Cart { -var $items; // Items in our shopping cart +var $items; // Artikel in unserem Einkaufswagen -// Add $num articles of $artnr to the cart +// Füge dem Einkaufswagen $num Artikel der Sorte $artnr zu function add_item ($artnr, $num) { $this-items[$artnr] += $num; } -// Take $num articles of $artnr out of the cart +// Nimm $num Artikel von $artnr aus dem Einkaufswagen function remove_item ($artnr, $num) { -43,50 +43,53 /para 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. +In diesem Beispiel wird eine Klasse Cart definiert. Sie +besteht aus einem assoziativen Array von Produkten im +Einkaufswagen und zwei Funktionen zum Hinzufügen und Entfernen von +Artikeln. /para caution simpara - The following cautionary notes are valid for PHP 4. + Die folgenden warnenden Bemerkungen gelten für PHP 4. /simpara - + simpara - The name literalstdClass/literal is used interally by - Zend and is reserved. You cannot have a class named - literalstdClass/literal in PHP. + Der Name literalstdClass/literal ist reserviert, da er intern + von Zend benutzt wird. Sie können in PHP keine Klasse mit dem + Namen literalstdClass/literal haben. /simpara - + simpara - The function names literal__sleep/literal and - literal__wakeup/literal are magical in PHP classes. You - cannot have functions with these names in any of your - classes unless you want the magic functionality associated - with them. See below for more information. + Die Funktionsnamen literal__sleep/literal und + literal__wakeup/literal sind in PHP Klassen magisch. Sie + können in Ihren Klassen keine Funktionen mit diesen Namen haben, + außer Sie wollen sie mit dieser magischen Funktionalität + assoziieren. Mehr Informationen dazu finden Sie weiter unten. /simpara - + simpara - PHP reserves all function names starting with __ as magical. - It is recommended that you do not use function names with - __ in PHP unless you want some documented magic functionality. + Sämtliche mit __ beginnende Funktionsnamen PHP als magisch + vorbehalten. Es wird empfohlen, in PHP keine Funktionsnamen mit + __ zu verwenden, außer Sie möchten dokumentierte magische + Funktionalität. /simpara /caution note simpara - In PHP 4, only constant initializers for literalvar/literal - variables are allowed. To initialize variables with non-constant - values, you need an initialization function which is called - automatically when an object is being constructed from the - class. Such a function is called a constructor (see below). + In PHP 4 sind nur konstante Initialisierungen für + literalvar/literal Variablen erlaubt. Um Variablen mit nicht + konstanten Werten zu initialisieren, benötigen Sie eine Funktion + zur Intitialisierung, welche beim Erstellen eines Objektes + automatisch von der Klasse aufgerufen wird. Eine solche Funktion + wird Konstruktor genannt (siehe unten). /simpara informalexample programlisting role=php ![CDATA[ ?php -/* None of these will work in PHP 4. */ +/* Keine wird in PHP 4 funktionieren */ class Cart { var $todays_date = date(Y-m-d); -95,7 +98,7 var $items = array(VCR, TV); } -/* This is how it should be done. */ +/* So sollte es gemacht werden */ class Cart { var $todays_date; -116,9 +119,9 /note para -Classes are types, that is, they are blueprints for actual -variables. You have to create a variable of the desired type with -the literalnew/literal operator. +Klassen sind Typen,
Re: [PHP-DOC] cvs: phpdoc /de/language oop.xml
Hello, you both are right. But since I've found out that en-file was already 5 times bigger than the de-version, I thought 100% English info is better than 20% German. And from the translation point of view it's in such a case also better to start from scratch than to look for some reuseable words. Anyhow, the translation will be ready till Moday. Cu, Thomas Egon Schmid wrote: From: Gabor Hojtsy [EMAIL PROTECTED] Please translate the comments in exampls back into German. It doesn´t make any sense to have English comments in a German PHP manual. The whole file seems to be comitted in English not German. Oops, haven´t read the huge commit not very carefull. Version 1.8 of de/language/oop.xml is English and version 1.7 is German. Thank you for reporting this. -Egon
[PHP-DOC] cvs: phpdoc /de/language oop.xml
tom Wed Mar 27 14:22:06 2002 EDT Modified files: /phpdoc/de/language oop.xml Log: file is finally complete now, translation will follow soon Index: phpdoc/de/language/oop.xml diff -u phpdoc/de/language/oop.xml:1.7 phpdoc/de/language/oop.xml:1.8 --- phpdoc/de/language/oop.xml:1.7 Wed Dec 12 15:46:22 2001 +++ phpdoc/de/language/oop.xml Wed Mar 27 14:22:06 2002 -1,30 +1,35 ?xml version=1.0 encoding=iso-8859-1? +!-- $Revision: 1.8 $ -- chapter id=language.oop - titleKlassen und Objekte/title + titleClasses and Objects/title sect1 id=keyword.class - titleliteralKlassen/literal/title + titleliteralclass/literal/title para -Eine Klasse ist eine Sammlung von Variablen und von Funktionen, -die mit diesen Variablen arbeiten. Eine Klasse wird folgendermaßen -definiert: +A class is a collection of variables and functions working with +these variables. A class is defined using the following syntax: + informalexample programlisting role=php -lt;?php -class Einkaufswagen { -var $produkte; // Produkte in Ihrem Einkaufswagen +![CDATA[ +?php +class Cart +{ +var $items; // Items in our shopping cart -// Füge dem Einkaufswagen $anzahl Artikel der Sorte $artnr zu +// Add $num articles of $artnr to the cart -function fuege_hinzu ($artnr, $anzahl) { -$this-produkte[$artnr] += $anzahl; +function add_item ($artnr, $num) +{ +$this-items[$artnr] += $num; } -// Nimm $anzahl von Artikel wieder aus dem Einkaufswagen +// Take $num articles of $artnr out of the cart -function nimm_heraus ($artnr, $anzahl) { -if ($this-produkte[$artnr] $anzahl) { -$this-produkte[$artnr] -= $anzahl; +function remove_item ($artnr, $num) +{ +if ($this-items[$artnr] $num) { +$this-items[$artnr] -= $num; return true; } else { return false; -32,122 +37,870 } } ? +]] /programlisting /informalexample /para + + 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 + + caution +simpara + The following cautionary notes are valid for PHP 4. +/simpara + +simpara + The name literalstdClass/literal is used interally by + Zend and is reserved. You cannot have a class named + literalstdClass/literal in PHP. +/simpara + +simpara + The function names literal__sleep/literal and + literal__wakeup/literal are magical in PHP classes. You + cannot have functions with these names in any of your + classes unless you want the magic functionality associated + with them. See below for more information. +/simpara + +simpara + PHP reserves all function names starting with __ as magical. + It is recommended that you do not use function names with + __ in PHP unless you want some documented magic functionality. +/simpara + /caution + + note +simpara + In PHP 4, only constant initializers for literalvar/literal + variables are allowed. To initialize variables with non-constant + values, you need an initialization function which is called + automatically when an object is being constructed from the + class. Such a function is called a constructor (see below). +/simpara +informalexample + programlisting role=php +![CDATA[ +?php +/* None of these will work in PHP 4. */ +class Cart +{ +var $todays_date = date(Y-m-d); +var $name = $firstname; +var $owner = 'Fred ' . 'Jones'; +var $items = array(VCR, TV); +} + +/* This is how it should be done. */ +class Cart +{ +var $todays_date; +var $name; +var $owner; +var $items; + +function Cart() +{ +$this-todays_date = date(Y-m-d); +$this-name = $GLOBALS['firstname']; +/* etc. . . */ +} +} +]] + /programlisting +/informalexample + /note + + para +Classes are types, that is, they are blueprints for actual +variables. You have to create a variable of the desired type with +the literalnew/literal operator. + /para + + informalexample +programlisting role=php +![CDATA[ +?php +$cart = new Cart; +$cart-add_item(10, 1); + +$another_cart = new Cart; +$another_cart-add_item(0815, 3); +]] +/programlisting + /informalexample + para -In diesem Beispiel wird eine Klasse Einkaufswagen definiert. Sie -besteht aus einem assoziativen Array von Produkten im -Einkaufswagen und zwei Funktionen zum Zufügen und Entfernen von -Einkäufen. +This creates the objects $cart and $another_cart, both of +the class Cart. The function add_item() of the $cart object +is being called to add 1 item of article number 10 to the +$cart. 3 items of article number 0815 are being added to +
Re: [PHP-DOC] cvs: phpdoc /de/language oop.xml
Please translate the comments in exampls back into German. It doesn´t make any sense to have English comments in a German PHP manual. -Egon - Original Message - From: Thomas Schoefbeck [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, March 27, 2002 8:22 PM Subject: [PHP-DOC] cvs: phpdoc /de/language oop.xml tom Wed Mar 27 14:22:06 2002 EDT Modified files: /phpdoc/de/language oop.xml Log: file is finally complete now, translation will follow soon
Re: [PHP-DOC] cvs: phpdoc /de/language oop.xml
Please translate the comments in exampls back into German. It doesn´t make any sense to have English comments in a German PHP manual. The whole file seems to be comitted in English not German. Goba
Re: [PHP-DOC] cvs: phpdoc /de/language oop.xml
From: Gabor Hojtsy [EMAIL PROTECTED] Please translate the comments in exampls back into German. It doesn´t make any sense to have English comments in a German PHP manual. The whole file seems to be comitted in English not German. Oops, haven´t read the huge commit not very carefull. Version 1.8 of de/language/oop.xml is English and version 1.7 is German. Thank you for reporting this. -Egon
[PHP-DOC] cvs: phpdoc /he/language oop.xml
barak Fri Jan 25 19:54:53 2002 EDT Added files: /phpdoc/he/language oop.xml Log: initial of translating this file Index: phpdoc/he/language/oop.xml +++ phpdoc/he/language/oop.xml ?xml version=1.0 encoding=iso-8859-1? !-- $Revision: 1.1 $ -- chapter id=language.oop titleClasses and Objects/title sect1 id=keyword.class titleliteralîçì÷åú/literal/title para îçì÷ä äéà àåñó ùì îùúðéí åôåð÷öéåú ùòåáãåú òí îùúðéí àìå. îçì÷ä îåâãøú úåê ùéîåù áúçáéø äáà: informalexample programlisting role=php ![CDATA[ ?php class Cart { var $items; // äâãøú îùúðä ùì äîçì÷ä áùí $items // Add $num articles of $artnr to the cart function add_item ($artnr, $num) { $this-items[$artnr] += $num; } // Take $num articles of $artnr out of the cart function remove_item ($artnr, $num) { if ($this-items[$artnr] $num) { $this-items[$artnr] -= $num; return true; } else { return false; } } } ? ]] /programlisting /informalexample /para para áãåâîà äðì, äåâãøä îçì÷ä ùùîä Cart, ùîåøëáú îîòøê äîùåééê ìôøéèéí ùáúåê áñì (Cart), åîùðé ôåð÷öéåú ìäåñôä (add) åìäñøä (remove) ùì ôøéèéí îúåê äòâìä. /para caution simpara äîãøéê äáà îúàéí ì PHP4 !. /simpara simpara äîéìä literalstdClass/literal äéà îéìä ùîåøä äðîöàú áùéîåù ôðéîé òì éãé ZEND. ìëï, àéï ìäùúîù áîéìä literalstdClass/literal á PHP. /simpara simpara ùí äôåð÷öéä literal__sleep/literal åùí äôåð÷öéä literal__wakeup/literal áòìåú ùéîåù îéåçã á - php. àúá ìà éëåì ìäùúîù áùí äæää ìàçú îùúé äôåð÷öéåú äðì áîçì÷ä ëìùäé àìà àí àúä øåöä ìäùúîù áäï ìàôùøåú äîéåçãú (ùúôåøè áäîùê) ùìä äï ðåòãå. øàä áäîùê äîãøéê ìîéãò ðåñó. /simpara simpara ëì ôåð÷öéåú ä PHP äîåôìàåú (áäîùê éôåøè îéãò ðåñó áðåùà) îúçéìåú òí __. îåîìõ îàåã ìà ì÷øåà ìùîåú ôåð÷öéä á PHP òí ùí äîúçéì á __ àìà àí àúä øåöä ìúòã àåúï ëôåð÷öéåú ÷ñåîåú. /simpara /caution note simpara á PHP 4, àéúçåì îùúðé îçì÷ä ùäåâãøå áòæøú literalvar/literal àôùøé ø÷ òí ÷áåòéí. ëãé ìàúçì îùúðéí, ùìà òì éãé òøëé ÷áåòéí, àúä öøéê ìäùúîù áôåð÷öéä ùð÷øàú àåèåîèéú òì éãé PHP ëàùø ðåöø àåáéé÷è çãù ùì äôåð÷öéä. ôåð÷öéä ëæàú ð÷øàú ôåð÷öéä áðàéú (constructor) (øàä ìîèä). /simpara informalexample programlisting role=php ![CDATA[ ?php /* áîçì÷ä äáàä, úâøåø äåãòú ùâéàä áâìì àéúçåì îùúðéí ùâåé ! */ class Cart { var $todays_date = date(Y-m-d); var $name = $firstname; var $owner = 'Fred ' . 'Jones'; var $items = array(VCR, TV); } /* ëëä æä àîåø ìäòùåú: */ class Cart { var $todays_date; var $name; var $owner; var $items; function Cart() // äáðàé ùì äîçì÷ä { $this-todays_date = date(Y-m-d); $this-name = $GLOBALS['firstname']; /* etc. . . */ } } ]] /programlisting /informalexample /note para îçì÷åú äï úáðéåú, ëìåîø, äï äëðä ìéöéøú îùúðéí àîéúééí (äàåáéé÷èéí) éåöøéí àú äîùúðéí îäñåâ äîáå÷ù úåê ùéîåù áàåôøèåø literalnew/literal. /para informalexample programlisting role=php ![CDATA[ ?php $cart = new Cart; $cart-add_item(10, 1); $another_cart = new Cart; $another_cart-add_item(0815, 3); ]] /programlisting /informalexample para äãåâîà äðì éöøä àú äàåáéé÷èéí $cart å $another_cart, ùðéäí àåáéé÷èéí ùðåöøå îäîçì÷ä Cart. äôåð÷öéä add_item() ùì äàåáéé÷è - $cart ð÷øàú òì îðú ìäåñéó ôøéè àçã ùì çôõ îñ' 10 ìúåê äòâìä. 3 ôøéèéí çôõ îñ' 0815 ðåñôå ìàåáéé÷è $another_cart. /para para âí ì $cart åâí ì $another_cart, éù àú äôåð÷öéåú add_item(), remove_item() åîùúðä ùì ôøéèéí ($items) . àìå äí ôåð÷öéåú åîùúðéí ðôøãéí. àôùø ìçùåá òì àåáéé÷èéí ëãåîéí ìñôøéåú å÷áöéí áîòøëú ÷áöéí. áúåê îòøëú ÷áöéí éëåìéí ìäéåú ìê ùðé ÷áöé README.TXT ùåðéí ìçìåèéï, ëì òåã äí ééîöàå áñôøéä àçøú. îîù ëîå áîòøëåú ÷áöéí, ëùöøéê ìäì÷éã àú äîñìåì äîìà òì îðú ìäôòéì ÷åáõ ëìùäå, àí ìà ðîöàéí áñôøéä ùìå, éù öåøê ìúú àú äùí äîìà ùì äôåð÷öéä àåúä øåöéí ìäôéì, áîåðçéí ùì php: øîú äâåáä ùì äàåáéé÷è ð÷áò áòæøú ùîåú ùäåâãøå, åîäôøéã áéï ùîåú àìå -gt;. ìëï, äîéìéí $cart-gt;items å $another_cart-gt;items äï ùîåú ùì ùúé îùúðéí àçøéí. éù ìùéí ìá ìòåáãä ùäîùúðä ð÷øà $cart-gt;items, åìà $cart-gt;$items, åæàú áùì, ùìùí îùúðä á PHP éù ø÷ ñéîï $ àçã. /para informalexample programlisting role=php ![CDATA[ // correct, single $ $cart-items = array(10 = 1); // ùâåé, áâìì ù $cart-$items äåôê ìäéåú $cart- $cart-$items = array(10 = 1); //ðëåï, àáì òìåì ìäéåú âí îùäå ùìà àìéå äúëååðå //$cart-$myvar äôê ìäéåú $cart-items $myvar = 'items'; $cart-$myvar = array(10 = 1); ]] /programlisting /informalexample para òí äâãøú äîçì÷ä, àéï àôùøåú ìãòú àéìå ùîåú àåáéé÷èéí ééåöøå áúåëðéú ìàåúä îçì÷ä: áæîï ùäîçì÷ä Cart
[PHP-DOC] cvs: phpdoc /hu/language oop.xml
gobaWed Jan 2 08:48:29 2002 EDT Modified files: /phpdoc/hu/language oop.xml Log: Correct unclosed tag Index: phpdoc/hu/language/oop.xml diff -u phpdoc/hu/language/oop.xml:1.9 phpdoc/hu/language/oop.xml:1.10 --- phpdoc/hu/language/oop.xml:1.9 Sat Dec 29 18:57:12 2001 +++ phpdoc/hu/language/oop.xml Wed Jan 2 08:48:29 2002 @@ -502,7 +502,7 @@ para A fenti példa meghívja az A osztály pelda() metódusát, habár nincs konkrét példányunk az A osztályból, -tehát ezt nem írhatnánk le az literal$a-pelda()literal-hoz +tehát ezt nem írhatnánk le az literal$a-pelda()/literal-hoz hasonlóan. Ehelyett a pelda() egy 'osztálymetódusként' viselkedik, azaz az osztály egy függvényeként, és nem egy példány metódusaként. /para
[PHP-DOC] cvs: phpdoc /it/language oop.xml
alan_dangeloSat Dec 22 16:32:04 2001 EDT Modified files: /phpdoc/it/language oop.xml Log: Update to En-Revision 1.32 Index: phpdoc/it/language/oop.xml diff -u phpdoc/it/language/oop.xml:1.11 phpdoc/it/language/oop.xml:1.12 --- phpdoc/it/language/oop.xml:1.11 Wed Dec 12 15:52:05 2001 +++ phpdoc/it/language/oop.xml Sat Dec 22 16:32:04 2001 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- EN-Revision: 1.31 Maintainer: alan_dangelo Status: ready -- +!-- EN-Revision: 1.32 Maintainer: alan_dangelo Status: ready -- chapter id=language.oop titleClassi e Oggetti/title
[PHP-DOC] cvs: phpdoc /pl/language oop.xml
leszek Thu Dec 20 07:52:57 2001 EDT Modified files: /phpdoc/pl/language oop.xml Log: Update Index: phpdoc/pl/language/oop.xml diff -u phpdoc/pl/language/oop.xml:1.6 phpdoc/pl/language/oop.xml:1.7 --- phpdoc/pl/language/oop.xml:1.6 Sun Dec 16 23:00:34 2001 +++ phpdoc/pl/language/oop.xml Thu Dec 20 07:52:57 2001 @@ -1,6 +1,6 @@ ?xml version=1.0 encoding=iso-8859-2? !-- EN-Revision: 1.30 Maintainer: leon Status: ready -- -!-- $Revision: 1.6 $ -- +!-- $Revision: 1.7 $ -- chapter id=language.oop titleKlasy i Obiekty/title
[PHP-DOC] cvs: phpdoc /ja/language oop.xml
fujimotoSun Dec 16 05:46:14 2001 EDT Modified files: /phpdoc/ja/language oop.xml Log: expanded tabs. Index: phpdoc/ja/language/oop.xml diff -u phpdoc/ja/language/oop.xml:1.14 phpdoc/ja/language/oop.xml:1.15 --- phpdoc/ja/language/oop.xml:1.14 Sun Dec 16 05:04:35 2001 +++ phpdoc/ja/language/oop.xml Sun Dec 16 05:46:14 2001 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=utf-8? -!-- $Revision: 1.14 $ -- +!-- $Revision: 1.15 $ -- chapter id=language.oop titleクラスとオブジェクト/title @@ -19,15 +19,15 @@ // $num 個の $artnr を買い物篭に加えます - function add_item ($artnr, $num) - { +function add_item ($artnr, $num) +{ $this-items[$artnr] += $num; } // $num 個の $artnr を買い物籠から出します - function remove_item ($artnr, $num) - { +function remove_item ($artnr, $num) +{ if ($this-items[$artnr] $num) { $this-items[$artnr] -= $num; return true; @@ -99,8 +99,8 @@ var $owner; var $items; - function Cart() - { +function Cart() +{ $this-todays_date = date(Y-m-d); $this-name = $GLOBALS['firstname']; /* 等など. . . */ @@ -208,8 +208,8 @@ { var $owner; - function set_owner ($name) - { +function set_owner ($name) +{ $this-owner = $name; } } @@ -714,7 +714,7 @@ { echo br,$this-Name; } - + function setName($name) { $this-Name = $name;
[PHP-DOC] cvs: phpdoc /ja/language oop.xml
fujimotoSun Dec 16 07:32:30 2001 EDT Modified files: /phpdoc/ja/language oop.xml Log: fixed typo. Index: phpdoc/ja/language/oop.xml diff -u phpdoc/ja/language/oop.xml:1.15 phpdoc/ja/language/oop.xml:1.16 --- phpdoc/ja/language/oop.xml:1.15 Sun Dec 16 05:46:14 2001 +++ phpdoc/ja/language/oop.xml Sun Dec 16 07:32:29 2001 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=utf-8? -!-- $Revision: 1.15 $ -- +!-- $Revision: 1.16 $ -- chapter id=language.oop titleクラスとオブジェクト/title @@ -320,7 +320,7 @@ { function A() { -echo Aのコンストラクタですlt;br\n; +echo Aのコンストラクタですbr\n; } } @@ -349,7 +349,7 @@ これは、PHP 4では、次のような別の規則が導入された修正されました。 あるクラスにコンストラクタがない場合、基底クラスのコンストラクタが ある場合にはコールされます。上の例は、PHP 4では、 -'Aのコンストラクタですlt;br'と出力されます。 +'Aのコンストラクタですlt;brgt;'と出力されます。 /para informalexample @@ -359,13 +359,13 @@ { function A() { -echo Aのコンストラクタですlt;br\n; +echo Aのコンストラクタですbr\n; } function B() { -echo クラスAのBという名前の通常の関数lt;br\n; -echo Aのコンストラクタではありませんlt;br\n; +echo クラスAのBという名前の通常の関数br\n; +echo Aのコンストラクタではありませんbr\n; } } @@ -373,7 +373,7 @@ { function C() { -echo 通常の関数ですlt;br\n; +echo 通常の関数ですbr\n; } } @@ -395,7 +395,7 @@ これは、PHP 4では次のように規則が修正されました。「コンストラクタ は、それが定義されているクラスと同じ名前の関数である」つまり、PHP 4では、クラスBが独自のコンストラクタ関数を持たない場合には、基底ク - ラスのコンストラクタがコールされ、「Aのコンストラクタですlt;br」 + +ラスのコンストラクタがコールされ、「Aのコンストラクタですlt;brgt;」 と出力されます。 /para @@ -529,7 +529,7 @@ { function example() { -echo A::example()です。基本関数を提供します。lt;br\n; +echo A::example()です。基本関数を提供します。br\n; } }
[PHP-DOC] cvs: phpdoc /pl/language oop.xml
leszek Sun Dec 16 23:00:35 2001 EDT Modified files: /phpdoc/pl/language oop.xml Log: Added comments for revcheck Index: phpdoc/pl/language/oop.xml diff -u phpdoc/pl/language/oop.xml:1.5 phpdoc/pl/language/oop.xml:1.6 --- phpdoc/pl/language/oop.xml:1.5 Wed Dec 12 15:56:22 2001 +++ phpdoc/pl/language/oop.xml Sun Dec 16 23:00:34 2001 @@ -1,5 +1,6 @@ ?xml version=1.0 encoding=iso-8859-2? -!-- $Revision: 1.5 $ -- +!-- EN-Revision: 1.30 Maintainer: leon Status: ready -- +!-- $Revision: 1.6 $ -- chapter id=language.oop titleKlasy i Obiekty/title @@ -882,7 +883,6 @@ sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t -indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:../../manual.ced sgml-exposed-tags:nil
[PHP-DOC] cvs: phpdoc /pl/language oop.xml
leszek Sat Dec 1 00:23:50 2001 EDT Modified files: /phpdoc/pl/language oop.xml Log: Updated to 1.31 Index: phpdoc/pl/language/oop.xml diff -u phpdoc/pl/language/oop.xml:1.3 phpdoc/pl/language/oop.xml:1.4 --- phpdoc/pl/language/oop.xml:1.3 Sat Nov 10 16:50:11 2001 +++ phpdoc/pl/language/oop.xml Sat Dec 1 00:23:50 2001 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-2? -!-- $Revision: 1.3 $ -- +!-- $Revision: 1.4 $ -- chapter id=language.oop titleKlasy i Obiekty/title @@ -11,7 +11,8 @@ informalexample programlisting role=php -lt;?php +![CDATA[ +?php class Koszyk { var $zakupy; // Zakupy w naszym koszyku @@ -35,7 +36,8 @@ } } } -?gt; +? +]] /programlisting /informalexample /para @@ -81,6 +83,7 @@ /simpara informalexample programlisting role=php +![CDATA[ /* Nic z tego nie bêdzie dzia³aæ w PHP 4. */ class Koszyk { @@ -105,6 +108,7 @@ /* itp. . . */ } } +]] /programlisting /informalexample /note @@ -116,11 +120,13 @@ informalexample programlisting role=php +![CDATA[ $koszyk = new Koszyk; $koszyk-dodaj_produkt(10, 1); $inny_koszyk = new Koszyk; $inny_koszyk-dodaj_produkt(0815, 3); +]] /programlisting /informalexample @@ -147,6 +153,7 @@ informalexample programlisting role=php +![CDATA[ // poprawnie, jeden $ $koszyk-artykuly = array(10 = 1); @@ -157,6 +164,7 @@ // $koszyk-$zmienna staje siê $koszyk-artykuly $zmienna = 'artykuly'; $koszyk-$zmienna = array(10 = 1); +]] /programlisting /informalexample @@ -194,6 +202,7 @@ informalexample programlisting role=php +![CDATA[ class Nazwany_Koszyk extends Koszyk { var $wlasciciel; @@ -203,6 +212,7 @@ $this-wlasciciel = $nazwa; } } +]] /programlisting /informalexample @@ -216,11 +226,13 @@ informalexample programlisting role=php +![CDATA[ $nkoszyk = new Nazwany_Koszyk;// Stwórz nazwany koszyk $nkoszyk-ustaw_wlasciciela(kris); // Nazwij koszyk print $nkoszyk-wlasciciel; // Wy¶wietl w³a¶ciciela koszyka $nkoszyk-dodaj_przedmiot(10, 1); // (funkcjonalno¶æ odziedziczona z // koszyka) +]] /programlisting /informalexample @@ -247,6 +259,7 @@ informalexample programlisting role=php +![CDATA[ // Dzia³a w PHP 3 i PHP 4. class Auto_Koszyk extends Koszyk { @@ -255,6 +268,7 @@ $this-dodaj_artykul (10, 1); } } +]] /programlisting /informalexample @@ -270,6 +284,7 @@ informalexample programlisting role=php +![CDATA[ // Dzia³a w PHP 3 i PHP 4. class Kontruktor_Koszyk extends Koszyk { @@ -286,6 +301,7 @@ // Czas na prawdziwe zakupy... $inny_koszyk = new Konstruktor_Koszyk(20, 17); +]] /programlisting /informalexample @@ -299,11 +315,12 @@ informalexample programlisting role=php +![CDATA[ class A { function A() { - echo Jestem konstruktorem klasy A.lt;br\n; + echo Jestem konstruktorem klasy A.br\n; } } @@ -311,12 +328,13 @@ { function C() { -echo Zwyk³a funkcja.lt;br\n; +echo Zwyk³a funkcja.br\n; } } // W PHP 3 nie zostanie wywo³any ¿aden konstruktor. $b = new B; +]] /programlisting /informalexample @@ -336,17 +354,18 @@ informalexample programlisting role=php +![CDATA[ class A { function A() { -echo Jestem konstruktorem klasy A.lt;br\n; +echo Jestem konstruktorem klasy A.br\n; } function B() { -echo Jestem zwyk³± funkcj± o nazwie B w klasie A.lt;br\n; -echo Nie jestem konstruktorem w klasie A.lt;br\n; +echo Jestem zwyk³± funkcj± o nazwie B w klasie A.br\n; +echo Nie jestem konstruktorem w klasie A.br\n; } } @@ -354,12 +373,13 @@ { function C() { -echo Jestem zwyk³± funkcj±.lt;br\n; +echo Jestem zwyk³± funkcj±.br\n; } } // Wywo³a to B() jako konstruktor. $b = new B; +]] /programlisting /informalexample @@ -419,11 +439,12 @@ informalexample programlisting role=php +![CDATA[ class A { function przyklad() { -echo Jestem orginaln± funkcj± A::przyklad().lt;br\n; +echo Jestem orginaln± funkcj± A::przyklad().br\n; } } @@ -431,23 +452,24 @@ { function przyklad() { -echo Jestem przedefiniowan± funkcj± B::przyklad().lt;br\n; +echo Jestem przedefiniowan± funkcj± B::przyklad().br\n; A::przyklad(); } } // nie ma obiektu klasy A. // poni¿sze wy¶wietli -// Jestem orginaln± funkcj± A::przyklad().lt;br +// Jestem orginaln± funkcj± A::przyklad().br A::przyklad(); // stwórz nowy obiekt klasy B. $b = new B; // poni¿sze wy¶wietli -// Jestem przedefiniowan± funkcj± B::przyklad().lt;br -// Jestem orginaln± funkcj± A::przyklad().lt;br +//
[PHP-DOC] cvs: phpdoc /it/language oop.xml
alan_dangeloSun Nov 25 10:38:31 2001 EDT Modified files: /phpdoc/it/language oop.xml Log: Add oop.xml EN-Revision 1.31 - Italian Translation Index: phpdoc/it/language/oop.xml diff -u /dev/null phpdoc/it/language/oop.xml:1.9 --- /dev/null Sun Nov 25 10:38:31 2001 +++ phpdoc/it/language/oop.xml Sun Nov 25 10:38:31 2001 @@ -0,0 +1,921 @@ +?xml version=1.0 encoding=iso-8859-1? +!-- EN-Revision: 1.31 Maintainer: alan_dangelo Status: ready -- + chapter id=language.oop + titleClassi e Oggetti/title + + sect1 id=keyword.class + titleliteralClassi/literal/title + para +Una classe è una collezione di variabili e funzioni che utilizzano +queste variabili. Una classe si definisce usando la seguente sintassi: + +informalexample + programlisting role=php +![CDATA[ +?php +class Cart +{ +var $items; // Articoli nel carrello + +// Aggiunge $num articoli di $artnr nel carrello + +function add_item ($artnr, $num) +{ +$this-items[$artnr] += $num; +} + +// Prende $num articoli di $artnr e li rimuove dal carrello + +function remove_item ($artnr, $num) +{ +if ($this-items[$artnr] $num) { +$this-items[$artnr] -= $num; +return true; +} else { +return false; +} +} +} +? +]] + /programlisting +/informalexample + /para + + para +Il codice definisce una classe chiamata Cart composta da un array +associativo che archivia gli articoli nel carrello e due funzioni +per aggiungere e rimuovere gli articoli dal carrello. + /para + + caution +simpara + Le seguenti note cautono valide per PHP 4. +/simpara + +simpara + Il nome literalstdClass/literal è usato esclusivamente da + Zend ed è riservato. Non è quindi possibile creare una classe chiamata + literalstdClass/literal in PHP. +/simpara + +simpara + I nomi di funzione literal__sleep/literal e + literal__wakeup/literal sono riservati e magici nelle classi PHP. + Non è possibile creare funzioni con questi nomi nelle classi definite + dall'utente a meno che non sia desiderata la funzionalità magica connessa + a questi nomi. Si veda sotto per avere più informazioni. +/simpara + +simpara + PHP riserva tutti i nomi di funzione che iniziano con __ a + funzioni magiche. Si suggerisce di non usare nomi di funzioni che utilizzano + __ in PHP a meno che non si desideri implementare una funzionalità magica. +/simpara + /caution + + note +simpara + In PHP 4, sono permesse inizializzazioni di variabili con valori + costanti solamente grazie all'uso di literalvar/literal. Per + inizializzare variabili con valori non-costanti, bisogna creare + una funzione d'inizializzazione che è chiamata automaticamente + all'istanziazione di un oggetto da una classe. Questo tipo di + funzione è chiamata costruttore (vedi sotto). +/simpara +informalexample + programlisting role=php +![CDATA[ +?php +/* questo non funziona in PHP 4. */ +class Cart +{ +var $todays_date = date(Y-m-d); +var $name = $firstname; +var $owner = 'Fred ' . 'Jones'; +var $items = array(VCR, TV); +} + +/* Questo è corretto. */ +class Cart +{ +var $todays_date; +var $name; +var $owner; +var $items; + +function Cart() +{ +$this-todays_date = date(Y-m-d); +$this-name = $GLOBALS['firstname']; +/* etc ... */ +} +} +]] + /programlisting +/informalexample + /note + + para +Le classi sono tipi del linguaggio, e sono modelli per +variabili reali. Per creare una variabile oggetto si usa +l'operatore literalnew/literal. + /para + + informalexample +programlisting role=php +![CDATA[ +?php +$cart = new Cart; +$cart-add_item(10, 1); + +$another_cart = new Cart; +$another_cart-add_item(0815, 3); +]] +/programlisting + /informalexample + + para +Il codice genera gli oggetti $cart e $another_cart, dalla classe +Cart. La funzione add_item() dell'oggetto $cart è chiamata per +aggiungere una ricorrenza dell'articolo numero 10 a $cart. +Ad $another_cart sono aggiunte 3 ricorrenze dell'articolo numero +0815. + /para + + para +Sia $cart che $another_cart dispongono delle funzioni add_item(), +remove_item() e della variabile $items, ma per ogni oggetto queste +sono funzioni e variabili distinte. Potete pensare agli oggetti come +a qualcosa di simile alle directories di un filesystem. In un +filesystem si possono avere due diversi files README.TXT, purchè +siano in directories differenti. Così come in un filesystem dovete +digitare il nome (percorso) completo per raggiungere un determinato +file partendo da una directory toplevel, così dovete specificare il +nome completo di una funzione o variabile che desiderate richiamare +da un oggetto.
[PHP-DOC] cvs: phpdoc /it/language oop.xml
alan_dangeloSun Nov 25 13:07:44 2001 EDT Modified files: /phpdoc/it/language oop.xml Log: Fixed some small error Index: phpdoc/it/language/oop.xml diff -u phpdoc/it/language/oop.xml:1.9 phpdoc/it/language/oop.xml:1.10 --- phpdoc/it/language/oop.xml:1.9 Sun Nov 25 10:38:31 2001 +++ phpdoc/it/language/oop.xml Sun Nov 25 13:07:44 2001 @@ -45,12 +45,12 @@ para Il codice definisce una classe chiamata Cart composta da un array associativo che archivia gli articoli nel carrello e due funzioni -per aggiungere e rimuovere gli articoli dal carrello. +per aggiungere e rimuovere gli articoli dal carrello stesso. /para caution simpara - Le seguenti note cautono valide per PHP 4. + Le seguenti note cautelari sono valide per PHP 4. /simpara simpara @@ -63,14 +63,14 @@ I nomi di funzione literal__sleep/literal e literal__wakeup/literal sono riservati e magici nelle classi PHP. Non è possibile creare funzioni con questi nomi nelle classi definite - dall'utente a meno che non sia desiderata la funzionalità magica connessa + dall'utente, a meno che non sia desiderata la funzionalità magica connessa a questi nomi. Si veda sotto per avere più informazioni. /simpara simpara PHP riserva tutti i nomi di funzione che iniziano con __ a funzioni magiche. Si suggerisce di non usare nomi di funzioni che utilizzano - __ in PHP a meno che non si desideri implementare una funzionalità magica. + con i caratteri __ in PHP a meno che non si desideri implementare una +funzionalità magica. /simpara /caution @@ -81,7 +81,7 @@ inizializzare variabili con valori non-costanti, bisogna creare una funzione d'inizializzazione che è chiamata automaticamente all'istanziazione di un oggetto da una classe. Questo tipo di - funzione è chiamata costruttore (vedi sotto). + funzione si chiama costruttore (vedi sotto). /simpara informalexample programlisting role=php @@ -136,7 +136,7 @@ /informalexample para -Il codice genera gli oggetti $cart e $another_cart, dalla classe +Il codice sopra, genera gli oggetti $cart e $another_cart, dalla classe Cart. La funzione add_item() dell'oggetto $cart è chiamata per aggiungere una ricorrenza dell'articolo numero 10 a $cart. Ad $another_cart sono aggiunte 3 ricorrenze dell'articolo numero @@ -146,7 +146,7 @@ para Sia $cart che $another_cart dispongono delle funzioni add_item(), remove_item() e della variabile $items, ma per ogni oggetto queste -sono funzioni e variabili distinte. Potete pensare agli oggetti come +sono funzioni e variabili sono distinte. Potete pensare agli oggetti come a qualcosa di simile alle directories di un filesystem. In un filesystem si possono avere due diversi files README.TXT, purchè siano in directories differenti. Così come in un filesystem dovete @@ -178,8 +178,8 @@ /informalexample para -Quand si definisce una classe, non è possibile prevedere quale nome avrà -l'oggetto istanziato nel programma. Quando la class Cart è stata scritta, +Quando si definisce una classe, non è possibile prevedere quale nome avrà +l'oggetto istanziato nel programma. Quando la classe Cart è stata scritta, non si poteva prevedere che l'oggetto istanziato da essa si sarebbe potuto chiamare $cart o $another_cart. Quindi non è possibile scrivere $cart-gt;items all'interno della classe Cart in fase di progettazione. Per poter accedere alle @@ -195,20 +195,17 @@ titleliteralextends/literal/title para -Spesso si avrà bisogno di avere classi con variabili e funzioni -simili ad altre classi. É buona norma definire una classe in modo -generico, così che possa essere usata in tutti quei progetti in -cui può essere utile e sia facile adattarla a bisogni più specifici. -Per facilitare questa operazione, è possibile generare classi per -estensione di altre classi. Una classe estesa o derivata ha tutte -le variabili e le funzioni della classe di base (questo fenomeno -è chiamato 'eredità', anche se non muore nessuno ... ma è come -se la classe estesa ereditasse geneticamente le sue caratteristiche -dalla sua classe base) più tutto ciò che viene aggiunto all'estensione. -Non è possibile che una sottoclasse, ridefinisca variabili e funzioni -di una classe madre. Una classe estesa dipende sempre da una singola -classe di base: l'eredità multipla non è supportata. Le classi si estendono -usando la parola chiave 'extends'. +Spesso si ha bisogno di avere classi con variabili e funzioni +simili ad altre classi. É buona norma perciò definire una classe in modo +generico, sia per poterla riutilizzare spesso, sia per poterla +adattare a scopi specifici.Per facilitare questa operazione, è
[PHP-DOC] cvs: phpdoc /fr/language oop.xml
damsSun Oct 28 11:43:19 2001 EDT Modified files: /phpdoc/fr/language oop.xml Log: Adding xml string.Updating with crowds of minors updates.Typos fixed. Index: phpdoc/fr/language/oop.xml diff -u phpdoc/fr/language/oop.xml:1.14 phpdoc/fr/language/oop.xml:1.15 --- phpdoc/fr/language/oop.xml:1.14 Sat Sep 8 12:54:52 2001 +++ phpdoc/fr/language/oop.xml Sun Oct 28 11:43:19 2001 @@ -1,4 +1,5 @@ -!-- $Revision: 1.14 $ -- +?xml encoding=iso-8859-1? +!-- $Revision: 1.15 $ -- chapter id=language.oop titleLes classes et les objets/title sect1 id=keyword.class @@ -31,9 +32,10 @@ /informalexample /para para -L'exemple ci-dessus deacute;finit la classe Caddie qui est composeacute;e d'un -tableau associatif contenant les articles du panier et de deux fonctions, -une pour ajouter et une pour enlever des eacute;leacute;ments au panier. +L'exemple ci-dessus deacute;finit la classe Caddie qui est composeacute;e +d'un tableau associatif contenant les articles du panier et de deux +fonctions, une pour ajouter et une pour enlever des eacute;leacute;ments +au panier. /para caution simpara @@ -41,8 +43,8 @@ /simpara simpara Le nom literalstdClass/literal est utiliseacute; en interne par - Zend et ne doit pas ecirc;tre utiliseacute;. Vous ne pouvez pas nommer une - classe literalstdClass/literal en PHP. + Zend et ne doit pas ecirc;tre utiliseacute;. Vous ne pouvez pas nommer + une classe literalstdClass/literal en PHP. /simpara simpara Les noms de fonctions literal__sleep/literal et @@ -51,11 +53,11 @@ que vous ne souhaitiez utiliser la magie qui y est associeacute;e. /simpara simpara - PHP se reacute;serve l'usage de tous les noms de fonctions commenccedil;ants par - literal__/literal, pour sa propre magie. Il est vivement - recommandeacute; de ne pas utilser des noms de fonctions commenccedil;ants par - literal__/literal, agrave; moins que vous ne souhaitiez utiliser - la magie qui y est associeacute;e. + PHP se reacute;serve l'usage de tous les noms de fonctions + commenccedil;ants par literal__/literal, pour sa propre magie. + Il est vivement recommandeacute; de ne pas utilser des noms de fonctions + commenccedil;ants par literal__/literal, agrave; moins que vous ne + souhaitiez utiliser la magie qui y est associeacute;e. /simpara /caution note @@ -247,6 +249,7 @@ /para informalexample programlisting role=php +lt;?php // Cette syntaxe est valable en PHP 3 et 4 class Constructor_Cart extends Cart { function Constructor_Cart ($item = 10, $num = 1) { @@ -257,6 +260,7 @@ $default_cart = new Constructor_Cart; // Creacute;ation d'un vrai caddie $different_cart = new Constructor_Cart (20, 17); +?gt; /programlisting /informalexample caution @@ -268,6 +272,7 @@ /caution informalexample programlisting role=php +lt;?php class A { function A() { echo Je suis le constructeur de A.lt;brgt;\n; @@ -280,6 +285,7 @@ } // Aucun constructeur n'est appeleacute; en PHP 3!! $b = new B; +?gt; /programlisting /informalexample para @@ -296,6 +302,7 @@ /para informalexample programlisting role=php +lt;?php class A { function A() { echo Je suis le constructeur de A.lt;brgt;\n; @@ -305,41 +312,47 @@ echo Je ne suis pas le constructeur de A.lt;brgt;\n; } } + class B extends A { function C() { -Je suis une fonction standard.lt;brgt;\n; +echo Je suis une fonction standard.lt;brgt;\n; } } // Cette syntaxe va appeler B() comme constructeur. $b = new B; +?gt; /programlisting /informalexample para En PHP 3, la fonction B() de la classe A va soudaiement devenir le -constructeur de la classe B, bien qu'il n'ai pas eacute;teacute; preacute;vu pour. -La regrave;gle de PHP 3 est 'Un constructeur est une fonction qui a le mecirc;me nom -que la classe'. PHP 3 ne se soucie guegrave;re si la fonction est deacute;finie -dans la classe B ou si elle a eacute;teacute; heacute;riteacute;e. +constructeur de la classe B, bien qu'il n'ai pas eacute;teacute; +preacute;vu pour. La regrave;gle de PHP 3 est 'Un constructeur est une +fonction qui a le mecirc;me nom que la classe'. PHP 3 ne se soucie +guegrave;re si la fonction est deacute;finie dans la classe B ou +si elle a eacute;teacute; heacute;riteacute;e. /para para -Ceci est corrigeacute; en PHP 4, avec l'introduction d'une nouvelle regrave;gle : -'Un constructeur est une classe de mecirc;me nom, deacute;finit dans la classe -elle-mecirc;me'. Donc, en PHP 4, la classe B n'a pas de constructeur par elle-mecirc;me, -et le constructeur de la classe A aura eacute;teacute; appeleacute;, affichant : +Ceci est corrigeacute; en PHP 4, avec l'introduction d'une nouvelle +regrave;gle : +
[PHP-DOC] cvs: phpdoc /en/language oop.xml
leszek Sat Oct 27 18:50:15 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: Typos Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.28 phpdoc/en/language/oop.xml:1.29 --- phpdoc/en/language/oop.xml:1.28 Fri Sep 21 18:47:48 2001 +++ phpdoc/en/language/oop.xml Sat Oct 27 18:50:15 2001 @@ -1,5 +1,5 @@ ?xml encoding=iso-8859-1? -!-- $Revision: 1.28 $ -- +!-- $Revision: 1.29 $ -- chapter id=language.oop titleClasses and Objects/title @@ -169,13 +169,13 @@ para Within a class definition, you do not know under which name the object will -be accessible in your program: At the time the Cart class was +be accessible in your program: at the time the Cart class was written, it was unknown that the object will be named $cart or $another_cart later. Thus, you cannot write $cart-gt;items within the Cart class itself. Instead, in order to be able to access it's own functions and variables from within a class, one can use the pseudo-variable $this which can be read as 'my own' or -'current object'. Thus, '$this-items[$artnr] += $num' can +'current object'. Thus, '$this-gt;items[$artnr] += $num' can be read as 'add $num to the $artnr counter of my own items array' or 'add $num to the $artnr counter of the items array within the current object'. @@ -675,7 +675,7 @@ Conversely, functionunserialize/function checks for the presence of a function with the magic name literal__wakeup/literal. If present, this function can - reconstruct any ressources that object may have. + reconstruct any resources that object may have. /para para
[PHP-DOC] cvs: phpdoc /en/language oop.xml
gobaMon Aug 20 09:34:07 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: Typo fixes Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.22 phpdoc/en/language/oop.xml:1.23 --- phpdoc/en/language/oop.xml:1.22 Mon Aug 20 07:55:11 2001 +++ phpdoc/en/language/oop.xml Mon Aug 20 09:34:06 2001 @@ -1,5 +1,5 @@ ?xml encoding=iso-8859-1? -!-- $Revision: 1.22 $ -- +!-- $Revision: 1.23 $ -- chapter id=language.oop titleClasses and Objects/title @@ -161,7 +161,7 @@ $cart-$items = array(10 = 1); // correct, but may or may not be what was intended: -// $cart-$myvar becomes $ncart-items +// $cart-$myvar becomes $cart-items $myvar = 'items'; $cart-$myvar = array(10 = 1); /programlisting @@ -190,7 +190,7 @@ to another existing class. In fact, it is good practice to define a generic class which can be used in all your projects and adapt this class for the needs of each of your -specific projects. To facilitate this, Classes can be +specific projects. To facilitate this, classes can be extensions of other classes. The extended or derived class has all variables and functions of the base class (this is called 'inheritance' despite the fact that nobody died) and what @@ -407,7 +407,7 @@ para Destructors are functions that are called automatically -when a variable is destroyed, either with functionunset/function +when an object is destroyed, either with functionunset/function or by simply going out of scope. There are no destructors in PHP. /para
[PHP-DOC] cvs: phpdoc /en/language oop.xml
gobaMon Aug 20 12:25:37 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: More typos fixed . object properties should start lowercased . some misspelled words, and bad examples corrected Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.25 phpdoc/en/language/oop.xml:1.26 --- phpdoc/en/language/oop.xml:1.25 Mon Aug 20 11:54:40 2001 +++ phpdoc/en/language/oop.xml Mon Aug 20 12:25:36 2001 @@ -1,5 +1,5 @@ ?xml encoding=iso-8859-1? -!-- $Revision: 1.25 $ -- +!-- $Revision: 1.26 $ -- chapter id=language.oop titleClasses and Objects/title @@ -710,12 +710,12 @@ function echoName() { -echo lt;brgt;,$this-Name; +echo lt;brgt;,$this-name; } function setName($name) { -$this-Name = $name; +$this-name = $name; } } /programlisting @@ -741,7 +741,7 @@ set in constructor set in constructor */ -$bar2 =amp; new foo('set in constructor'); +$bar2 =amp; new Foo('set in constructor'); $bar2-echoName(); $globalref[1]-echoName(); @@ -761,7 +761,7 @@ return a reference by default, instead it returns a copy. note simpara - There is no performance loss (since php 4 and up use reference + There is no performance loss (since PHP 4 and up use reference counting) returning copies instead of references. On the contrary it is most often better to simply work with copies instead of references, because creating references takes some @@ -776,7 +776,7 @@ informalexample programlisting role=php // now we will change the name. what do you expect? -// you could expect that both $bar and $globalref[0] change their names... +// you could expect that both $bar1 and $globalref[0] change their names... $bar1-setName('set from outside'); // as mentioned before this is not the case. @@ -784,14 +784,14 @@ $globalref[0]-echoName(); /* output: -set on object creation -set from outside */ +set from outside +set in constructor */ // let us see what is different with $bar2 and $globalref[1] $bar2-setName('set from outside'); -// luckily they are not only equyl, they are thesame variable -// thus $bar2-Name and $globalref[1]-Name are the same too +// luckily they are not only equal, they are the same variable +// thus $bar2-name and $globalref[1]-name are the same too $bar2-echoName(); $globalref[1]-echoName();
[PHP-DOC] cvs: phpdoc /en/language oop.xml
gobaWed Aug 15 04:27:44 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: Closing bug #12750 (echo was missing) Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.19 phpdoc/en/language/oop.xml:1.20 --- phpdoc/en/language/oop.xml:1.19 Thu Aug 2 13:37:47 2001 +++ phpdoc/en/language/oop.xml Wed Aug 15 04:27:44 2001 @@ -1,4 +1,4 @@ -!-- $Revision: 1.19 $ -- +!-- $Revision: 1.20 $ -- chapter id=language.oop titleClasses and Objects/title @@ -303,7 +303,7 @@ class B extends A { function C() { -I am a regular function.lt;br\n; +echo I am a regular function.lt;br\n; } }
[PHP-DOC] cvs: phpdoc /fr/language oop.xml
damsWed Aug 8 05:47:25 2001 EDT Modified files: /phpdoc/fr/language oop.xml Log: Synch with en tree Index: phpdoc/fr/language/oop.xml diff -u phpdoc/fr/language/oop.xml:1.12 phpdoc/fr/language/oop.xml:1.13 --- phpdoc/fr/language/oop.xml:1.12 Fri Jul 20 03:10:14 2001 +++ phpdoc/fr/language/oop.xml Wed Aug 8 05:47:25 2001 @@ -1,3 +1,4 @@ +!-- $Revision: 1.13 $ -- chapter id=language.oop titleLes classes et les objets/title sect1 id=keyword.class @@ -512,7 +513,7 @@ $s = serialize($a); // enregistrez $s ougrave; la page2.php pourra le trouver. $fp = fopen(store, w); - echo $s; + fputs($fp, $s); fclose($fp); ?gt; page2.php:
[PHP-DOC] cvs: phpdoc /en/language oop.xml
gobaThu Aug 2 07:53:38 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: Corrected perlish file write (echo??) and a typo in text Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.17 phpdoc/en/language/oop.xml:1.18 --- phpdoc/en/language/oop.xml:1.17 Sat Jul 7 17:27:20 2001 +++ phpdoc/en/language/oop.xml Thu Aug 2 07:53:38 2001 @@ -576,7 +576,7 @@ $s = serialize($a); // store $s somewhere where page2.php can find it. $fp = fopen(store, w); - echo $s; + fputs($fp, $s); fclose($fp); page2.php: @@ -612,7 +612,7 @@ /para para - So if the in the example above $a became part of a session by + So if in the example above $a became part of a session by running literalsession_register(a)/literal, you should include the file literalclassa.inc/literal on all of your pages, not only page1.php and page2.php.
[PHP-DOC] cvs: phpdoc /fr/language oop.xml
damsFri Jul 20 03:10:14 2001 EDT Modified files: /phpdoc/fr/language oop.xml Log: do_foo - faire_foo Index: phpdoc/fr/language/oop.xml diff -u phpdoc/fr/language/oop.xml:1.11 phpdoc/fr/language/oop.xml:1.12 --- phpdoc/fr/language/oop.xml:1.11 Mon Mar 19 12:06:31 2001 +++ phpdoc/fr/language/oop.xml Fri Jul 20 03:10:14 2001 @@ -1,5 +1,5 @@ chapter id=language.oop - titleClasses et objets/title + titleLes classes et les objets/title sect1 id=keyword.class titleLes classes : literalclass/literal/title para @@ -34,6 +34,29 @@ tableau associatif contenant les articles du panier et de deux fonctions, une pour ajouter et une pour enlever des eacute;leacute;ments au panier. /para + caution +simpara + Les notes suivantes ne sont valable que pour PHP 4. +/simpara +simpara + Le nom literalstdClass/literal est utiliseacute; en interne par + Zend et ne doit pas ecirc;tre utiliseacute;. Vous ne pouvez pas nommer une + classe literalstdClass/literal en PHP. +/simpara +simpara + Les noms de fonctions literal__sleep/literal et + literal__wakeup/literal sont magiques en PHP. Vous ne pouvez + pas utiliser ces noms de fonctions dans vos classes, agrave; moins + que vous ne souhaitiez utiliser la magie qui y est associeacute;e. +/simpara +simpara + PHP se reacute;serve l'usage de tous les noms de fonctions commenccedil;ants +par + literal__/literal, pour sa propre magie. Il est vivement + recommandeacute; de ne pas utilser des noms de fonctions commenccedil;ants par + literal__/literal, agrave; moins que vous ne souhaitiez utiliser + la magie qui y est associeacute;e. +/simpara + /caution note simpara En PHP 4, seuls les initialiseurs constants pour les variables @@ -49,19 +72,21 @@ var $date_du_jour = date(d/m/Y); var $name = $firstname; var $owner = 'Fred ' . 'Jones'; +var $items = array(DVD, Teacute;leacute;,Magneacute;toscope); } /* Voici comment cela doit se faire deacute;sormais. */ class Caddie { var $date_du_jour; var $name; var $owner; +var $items; function Caddie() { $this-date_du_jour = date(d/m/Y); $this-name = $GLOBALS['firstname']; /* etc... */ } } -?lt; +?gt; /programlisting /informalexample /note @@ -74,21 +99,75 @@ lt;?php $cart = new Caddie; $cart-add_item(10, 1); + $another_cart = new Cart; + $another_cart-add_item(0815, 3); ?gt; /programlisting /informalexample para L'instruction ci-dessus creacute;e l'objet $cart de la class Caddie. La fonction add_idem() est appeleacute;e afin d'ajouter l'article -numeacute;ro 10 dans la panier. +numeacute;ro 10 dans le panier. 3 articles numeacute;ro 0815 sont +ajouteacute;s au +cart $another_cart. /para para -Une classe peut ecirc;tre une extension d'une autre classe. -Les classes extended ou derived heacute;ritent de toutes -les variables et de toutes les fonctions de la classe pegrave;re -plus toutes les deacute;finitions que vous rajoutez agrave; cette -classe. Cela se fait avec le mot clef extends. -L'heacute;ritage multiple n'est pas supporteacute;. +$cart et $another_cart disposent des fonctions add_item(), +remove_item() et de la variable items. Ce sont des fonctions +et variables distinctes. Vous pouvez vous repreacute;senter les +objets comme des dossiers sur votre disque dur. Vous pouvez +avoir deux fichiers lisez-moi.txt sur votre disque dur, tant qu'ils +ne sont pas dans le mecirc;me reacute;pertoire. De mecirc;me que vous devez +alors +taper le chemin complet jusqu'au fichier, vous devez speacute;cifier +le nom complet de la meacute;thode avant de l'employer : en termes PHP, +le dossier racine est l'espace de nom global, et le seacute;parateur +de dossier est literal-gt;/literal. Par exemple, les noms +$cart-gt;items et $another_cart-gt;items repreacute;sentent deux +variables distinctes. Notez que le nom de la variable est alors +$cart-gt;items, et non pas $cart-gt;$items : il n'y a qu'un seul +signe $ dans un nom de variable. + /para + informalexample +programlisting role=php +lt;?php +// correct, $ unique +$cart-items = array(10 = 1); +// incorrect, car $cart-$items devient $cart- +$cart-$items = array(10 = 1); +// correct, mais risque de ne pas se comporter comme preacute;vu +// $cart-$myvar devient $ncart-items +$myvar = 'items'; +$cart-$myvar = array(10 = 1); +?gt; +/programlisting + /informalexample + para +A l'inteacute;rieur d'une deacute;finition de classe, vous ne savez pas le +nom de la variable agrave; partir duquel l'objet sera accessible dans +le script. On ne peut preacute;voir que l'objet creacute;eacute; sera +affecteacute; agrave; +la variable $cart ou $another_cart. Donc, vous ne pouvez pas +
[PHP-DOC] cvs: phpdoc /it/language oop.xml
peruginiTue Jul 3 09:29:16 2001 EDT Modified files: /phpdoc/it/language oop.xml Log: Fixing make problem. Index: phpdoc/it/language/oop.xml diff -u phpdoc/it/language/oop.xml:1.3 phpdoc/it/language/oop.xml:1.4 --- phpdoc/it/language/oop.xml:1.3 Thu Aug 31 02:32:24 2000 +++ phpdoc/it/language/oop.xml Tue Jul 3 09:29:16 2001 @@ -1,150 +1,828 @@ chapter id=language.oop - titleClassi ed Oggetti/title + titleClasses and Objects/title sect1 id=keyword.class titleliteralclass/literal/title para -Una classe egrave; una collezione di variabili e funzioni che -ne fanno uso. Una classe viene definita utilizzando la seguente sintassi: +A class is a collection of variables and functions working with +these variables. A class is defined using the following syntax: informalexample programlisting role=php lt;?php -class Carrello { -var $articoli; // Articoli nel carrello della spesa +class Cart { +var $items; // Items in our shopping cart -// Aggiungi $num articoli di $artnr al carrello +// Add $num articles of $artnr to the cart -function aggiungi_articoli ($artnr, $num) { -$this-articoli[$artnr] += $num; +function add_item ($artnr, $num) { +$this-items[$artnr] += $num; } -// Elimina $num articoli di $artnr dal carrello +// Take $num articles of $artnr out of the cart -function rimuovi_articoli ($artnr, $num) { -if ($this-articoli[$artnr] $num) { -$this-articoli[$artnr] -= $num; +function remove_item ($artnr, $num) { +if ($this-items[$artnr] $num) { +$this-items[$artnr] -= $num; return true; } else { return false; } } } -? +?gt; /programlisting /informalexample /para para -Ciograve; definisce una classe chiamata Carrello che consiste in un -vettore associativo di articoli e di due funzioni per aggiungere e rimuovere -gli articoli nel carrello stesso. +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 + + caution +simpara + The following cautionary notes are valid for PHP 4. +/simpara + +simpara + The name literalstdClass/literal is used interally by + Zend and is reserved. You cannot have a class named + literalstdClass/literal in PHP. +/simpara + +simpara + The function names literal__sleep/literal and + literal__wakeup/literal are magical in PHP classes. You + cannot have functions with these names in any of your + classes unless you want the magic functionality associated + with them. See below for more information. +/simpara + +simpara + PHP reserves all function names starting with __ as magical. + It is recommended that you do not use function names with + __ in PHP unless you want some documented magic functionality. +/simpara + /caution + + note +simpara + In PHP 4, only constant initializers for literalvar/literal + variables are allowed. To initialize variables with non-constant + values, you need an initialization function which is called + automatically when an object is being constructed from the + class. Such a function is called a constructor (see below). +/simpara +informalexample + programlisting role=php +/* None of these will work in PHP 4. */ +class Cart { +var $todays_date = date(Y-m-d); +var $name = $firstname; +var $owner = 'Fred ' . 'Jones'; +var $items = array(VCR, TV); +} + +/* This is how it should be done. */ +class Cart { +var $todays_date; +var $name; +var $owner; +var $items; + +function Cart() { +$this-todays_date = date(Y-m-d); +$this-name = $GLOBALS['firstname']; +/* etc. . . */ +} +} + /programlisting +/informalexample + /note + para -Le classi sono tipi, ovvero, sono schemi per variabili. -Per utilizzarle occorre crearne una variabile istanza del tipo (classe) desiderato tramite l'operatore new. +Classes are types, that is, they are blueprints for actual +variables. You have to create a variable of the desired type with +the literalnew/literal operator. /para informalexample programlisting role=php - $carrello = new Carrello; - $carrello-aggiungi_articoli(10, 1); + $cart = new Cart; + $cart-add_item(10, 1); + + $another_cart = new Cart; + $another_cart-add_item(0815, 3); /programlisting /informalexample + para +This creates the objects $cart and $another_cart, both of +the class Cart. The function add_item() of the $cart object +is being called to add 1 item of article number 10 to the +$cart. 3 items of article number 0815 are being added to +$another_cart. +
Re: [PHP-DOC] cvs: phpdoc /en/language oop.xml
Daniel Beckham wrote: It looks like you might have truncated this sentence in the language.oop.serialization section of oop.xml: caution simpara The following information is valid for PHP4 only. In PHP3, an /simpara /caution Thanks for hinting. I'll fix. Kristian -- Kristian Köhntopp, NetUSE AG Dr.-Hell-Straße, D-24107 Kiel Tel: +49 431 386 435 00, Fax: +49 431 386 435 99
Re: [PHP-DOC] cvs: phpdoc /en/language oop.xml
On Fri, May 18, 2001 at 09:41:39AM +0200, Kristian Köhntopp wrote: Daniel Beckham wrote: It looks like you might have truncated this sentence in the language.oop.serialization section of oop.xml: caution simpara The following information is valid for PHP4 only. In PHP3, an /simpara /caution Thanks for hinting. I'll fix. Than write PHP 4 and PHP 3. -Egon -- LinuxTag, Stuttgart, Germany: July 5-8 2001: http://www.linuxtag.de/ All known books about PHP and related books: http://php.net/books.php Concert Band of the University of Hohenheim: http://www.concert-band.de/ First and second bestselling book in German: http://www.php-buch.de/
[PHP-DOC] cvs: phpdoc /en/language oop.xml
kk Thu May 17 16:05:01 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: - Extended documentation for object orientation. This should now cover most, if not all features of PHP 4 object orientation, reflecting the greatly improved OO features in PHP 4. - The documentation for serialize() and unserialize() is still stating that class associations are lost. This is no longer true in PHP 4 and should be corrected. It is now 1am here. I am not going to fix that now, someone else should. Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.11 phpdoc/en/language/oop.xml:1.12 --- phpdoc/en/language/oop.xml:1.11 Fri Mar 9 15:26:42 2001 +++ phpdoc/en/language/oop.xml Thu May 17 16:05:01 2001 @@ -41,11 +41,39 @@ items from this cart. /para + caution +simpara + The following cautionary note are valid for PHP4. +/simpara + +simpara + The name literalstdClass/literal is used interally by + Zend and is reserved. You cannot have a class named + literalstdClass/literal in PHP. +/simpara + +simpara + The function names literal__sleep/literal and + literal__wakeup/literal are magical in PHP classes. You + cannot have functions with these names in any of your + classes unless you want the magic functionality associated + with them. See below for more information. +/simpara + +simpara + PHP reserves all function names starting with __ as magical. + It is recommended that you do not use function names with + __ in PHP unless you want some documented magic functionality. +/simpara + /caution + note simpara In PHP 4, only constant initializers for literalvar/literal - variables are allowed. Use constructors for non-constant - initializers. + variables are allowed. To initialize variables with non-constant + values, you need an initialization function which is called + automatically when an object is being constructed from the + class. Such a function is called a constructor (see below). /simpara informalexample programlisting role=php @@ -80,20 +108,86 @@ informalexample programlisting role=php -$cart = new Cart; -$cart-add_item(10, 1); + $cart = new Cart; + $cart-add_item(10, 1); + + $another_cart = new Cart; + $another_cart-add_item(0815, 3); /programlisting /informalexample + para +This creates the objects $cart and $another_cart, both of +the class Cart. The function add_item() of the $cart object +is being called to add 1 item of article number 10 to the +$cart. 3 items of article number 0815 are being added to +$another_cart. + /para + 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. /parapara 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 -definition. This is done using the extends keyword. Multiple -inheritance is not supported. +Both, $cart and $another_cart, have functions add_item(), +remove_item() and a variable items. These are distinct functions and +variables. You can think of the objects as something like +directories in a filesystem, where you can have two different +files README.TXT, as long as they are in different directories, +and you'll have to type the full pathname in order to reach each +file from the toplevel directory. In PHP terms, the toplevel +directory would be the global namespace, and the pathname separator +would be -gt;. Thus, the names $cart-gt;items and +$another_cart-gt;items name two different variables. Note +that the variable is named $cart-gt;items, not +$cart-gt;$items, that is, a variable name in PHP has only a +single dollar sign. /para + + informalexample +programlisting role=php +// correct, single $ +$cart-items = array(10 = 1); + +// invalid, because $cart-$items becomes $cart- +$cart-$items = array(10 = 1); + +// correct, but may or may not be what was intended: +// $cart-$myvar becomes $ncart-items +$myvar = 'items'; +$cart-$myvar = array(10 = 1); +/programlisting + /informalexample + + para +Within a class, you do not know under which name the object will +be accessible in your program: At the time the Cart class was +written, it was unknown that the object will be named $cart or +$another_cart later. Thus, you cannot write $cart-gt;items within +the Cart class. Instead, in order to be able to access it's own +functions and variables from within a class, one can use the +pseudo-variable $this which can be read as 'my own' or +'current object'. Thus, '$this-items[$artnr] += $num' can +
Re: [PHP-DOC] cvs: phpdoc /en/language oop.xml
I'll correct those two functions for you tonight. Daniel - Original Message - From: Kristian Köhntopp [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, May 17, 2001 6:05 PM Subject: [PHP-DOC] cvs: phpdoc /en/language oop.xml kk Thu May 17 16:05:01 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: - Extended documentation for object orientation. This should now cover most, if not all features of PHP 4 object orientation, reflecting the greatly improved OO features in PHP 4. - The documentation for serialize() and unserialize() is still stating that class associations are lost. This is no longer true in PHP 4 and should be corrected. It is now 1am here. I am not going to fix that now, someone else should.
Re: [PHP-DOC] cvs: phpdoc /en/language oop.xml
It looks like you might have truncated this sentence in the language.oop.serialization section of oop.xml: caution simpara The following information is valid for PHP4 only. In PHP3, an /simpara /caution Daniel - Original Message - From: Kristian Köhntopp [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, May 17, 2001 6:05 PM Subject: [PHP-DOC] cvs: phpdoc /en/language oop.xml kk Thu May 17 16:05:01 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: - Extended documentation for object orientation. This should now cover most, if not all features of PHP 4 object orientation, reflecting the greatly improved OO features in PHP 4. - The documentation for serialize() and unserialize() is still stating that class associations are lost. This is no longer true in PHP 4 and should be corrected. It is now 1am here. I am not going to fix that now, someone else should.
[PHP-DOC] cvs: phpdoc /en/language oop.xml
andre Fri Mar 9 13:45:33 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: Adding documentation for references inside the constructor Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.7 phpdoc/en/language/oop.xml:1.8 --- phpdoc/en/language/oop.xml:1.7 Thu Feb 22 16:43:23 2001 +++ phpdoc/en/language/oop.xml Fri Mar 9 13:45:32 2001 @@ -30,7 +30,7 @@ } } } -? +?gt; /programlisting /informalexample /para @@ -195,6 +195,176 @@ /simpara /caution /sect1 + + sect1 id="keyword.newref" + titlereferences inside the constructor/title + para +Creating references within the constructor can lead to confusing results. This +tutorial like section helps you +to avoid problems. + +informalexample + programlisting role="php" + +class foo { +function foo($name) { +// create a reference inside the global array $globalref +global $globalref; + $globalref[] = $this; +// set name to passed value +$this-setName($name); + // and put it out +$this-echoName(); +} + +function echoName() { +echo "br",$this-Name; +} + + function setName($name) { + $this-Name = $name; +} +} +/programlisting + /informalexample + + para + Let us check out if there is a difference between varname$bar1/varname which +has been created using the copy literal=/literal operator + and varname$bar2/varname which has been created using the reference +literal=/literal operator... + /para + +informalexample + programlisting role="php" + +$bar1 = new foo('set in constructor'); +$bar1-echoName(); +$globalref[0]-echoName(); + +/* output: +set in constructor +set in constructor +set in constructor */ + +$bar2 = new foo('set in constructor'); +$bar2-echoName(); +$globalref[1]-echoName(); + +/* output: +set in constructor +set in constructor +set in constructor */ + +/programlisting + /informalexample + + para +Apparently there is no difference, but in fact there is a very significant one: +varname$bar1/varname and varname$globalref[0]/varname are _NOT_ +referenced, they are NOT the same variable. +This is because "new" does not return a reference by default, instead it returns +a copy. + note + simpara + There is no performance loss (since php 4 and up use reference counting) +returning copies instead of references. + On the contrary it is most often better to simply work with copies instead +of references, because creating + references takes some time where creating copies virtually takes no time +(unless none of them is a large array or object + and one of them gets changed and the other(s) one(s) subsequently, then it +would be wise to use references to change them + all concurrently). + /simpara +/note +To prove what is written above let us watch the code below. + /para + + informalexample + programlisting role="php" +// now we will change the name. what do you expect? +// you could expect that both $bar and $globalref[0] change their names... +$bar1-setName('set from outside'); + +// as mentioned before this is not the case. +$bar1-echoName(); +$globalref[0]-echoName(); + +/* output: +set on object creation +set from outside */ + +// let us see what is different with $bar2 and $globalref[1] +$bar2-setName('set from outside'); + +// luckily they are not only equyl, they are thesame variable +// thus $bar2-Name and $globalref[1]-Name are the same too +$bar2-echoName(); +$globalref[1]-echoName(); + +/* output: +set from outside +set from outside */ + + /programlisting + /informalexample + + para + Another final example, try to understand it. + + informalexample + programlisting role="php" + +class a { +function a($i) { +$this-value = $i; +// try to figure out why we do not need a reference here +$this-b = new b($this); +} + +function createRef() { +$this-c = new b($this); +} + +function echoValue() { +echo "br","class ",get_class($this),': ',$this-value; +} +} + + +class b { + +function b($a) { +$this-a = $a; +} + + function echoValue() { +echo "br","class ",get_class($this),': ',$this-a-value; +} + +} + +// try to undestand why using a simple copy here would yield +// in an undesired result in the *-marked line +$a = new a(10); +$a-createRef(); + +$a-echoValue(); +$a-b-echoValue(); +$a-c-echoValue(); + +$a-value = 11; + +$a-echoValue(); +$a-b-echoValue(); // * +$a-c-echoValue(); + +/* +output: +class a: 10 +class b: 10
[PHP-DOC] cvs: phpdoc /en/language oop.xml
andre Fri Mar 9 15:20:35 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: cosmetic fix Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.9 phpdoc/en/language/oop.xml:1.10 --- phpdoc/en/language/oop.xml:1.9 Fri Mar 9 14:29:02 2001 +++ phpdoc/en/language/oop.xml Fri Mar 9 15:20:34 2001 @@ -196,11 +196,11 @@ /caution /sect1 - sect1 id="keyword.newref" - titlereferences inside the constructor/title + sect1 id="language.oop.newref" + titleReferences inside the constructor/title para Creating references within the constructor can lead to confusing results. This tutorial like section helps you -to avoid problems. +to avoiding this kind of problems. informalexample programlisting role="php"
[PHP-DOC] cvs: phpdoc /en/language oop.xml
torben Fri Mar 9 15:26:42 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: Was more correct before. Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.10 phpdoc/en/language/oop.xml:1.11 --- phpdoc/en/language/oop.xml:1.10 Fri Mar 9 15:20:34 2001 +++ phpdoc/en/language/oop.xml Fri Mar 9 15:26:42 2001 @@ -199,8 +199,8 @@ sect1 id="language.oop.newref" titleReferences inside the constructor/title para -Creating references within the constructor can lead to confusing results. This tutorial like section helps you -to avoiding this kind of problems. +Creating references within the constructor can lead to confusing +results. This tutorial-like section helps you to avoid problems. informalexample programlisting role="php"
[PHP-DOC] cvs: phpdoc /en/language oop.xml
torben Thu Feb 22 16:43:23 2001 EDT Modified files: /phpdoc/en/language oop.xml Log: Added an example to help clarify the lack of non-constant variable initializers in classes in PHP 4 (spurred by Bug #9414). Index: phpdoc/en/language/oop.xml diff -u phpdoc/en/language/oop.xml:1.6 phpdoc/en/language/oop.xml:1.7 --- phpdoc/en/language/oop.xml:1.6 Fri Feb 9 11:41:08 2001 +++ phpdoc/en/language/oop.xml Thu Feb 22 16:43:23 2001 @@ -40,10 +40,38 @@ array of articles in the cart and two functions to add and remove items from this cart. /para - notesimpara - In PHP 4, only constant initializers for literalvar/literal - variables are allowed. Use constructors for non-constant initializers. - /simpara/note + + note +simpara + In PHP 4, only constant initializers for literalvar/literal + variables are allowed. Use constructors for non-constant + initializers. +/simpara +informalexample + programlisting role="php" +/* None of these will work in PHP 4. */ +class Cart { +var $todays_date = date("Y-m-d"); +var $name = $firstname; +var $owner = 'Fred ' . 'Jones'; +} + +/* This is how it should be done. */ +class Cart { +var $todays_date; +var $name; +var $owner; + +function Cart() { +$this-todays_date = date("Y-m-d"); +$this-name = $GLOBALS['firstname']; +/* etc. . . */ +} +} + /programlisting +/informalexample + /note + para Classes are types, that is, they are blueprints for actual variables. You have to create a variable of the desired type with @@ -52,8 +80,8 @@ informalexample programlisting role="php" - $cart = new Cart; - $cart-add_item("10", 1); +$cart = new Cart; +$cart-add_item("10", 1); /programlisting /informalexample
[PHP-DOC] cvs: phpdoc /fr/language oop.xml
damsMon Feb 19 00:57:33 2001 EDT Modified files: /phpdoc/fr/language oop.xml Log: Removed some illegal chars. Index: phpdoc/fr/language/oop.xml diff -u phpdoc/fr/language/oop.xml:1.5 phpdoc/fr/language/oop.xml:1.6 --- phpdoc/fr/language/oop.xml:1.5 Mon Feb 12 00:16:18 2001 +++ phpdoc/fr/language/oop.xml Mon Feb 19 00:57:33 2001 @@ -103,21 +103,19 @@ eacute;gale agrave; l'objet de la classe. Vous pouvez utilisez la forme "$this-quelquechose" pour acceacute;der aux fonctions ou aux variables de l'objet courant. Aussi bien - depuis l'objet lui-mme que de l'exteacute;rieur, vous n'avez pas - besoin de literal$/literal pour acceacute;der aux + depuis l'objet lui-mecirc;me que de l'exteacute;rieur, vous n'avez pas + besoin de literal$/literal pour acceacute;der aux proprieacute;teacute;s d'un objet. /para informalexample programlisting role="php" lt;?php $ncart-owner = "chris"; // pas de '$' - $ncart-$owner = "chris"; -// Ceci est invalide, car $ncart-$owner eacute;quivaut $ncart-"" - +// Ceci est invalide, car $ncart-$owner eacute;quivaut agrave; $ncart-"" $myvar = 'owner'; -$ncart-$myvar = "chris"; -// Ceci est valide, car $ncart-$owner eacute;quivaut $ncart-owner +$ncart-$myvar = "chris"; +// Ceci est valide, car $ncart-$owner eacute;quivaut agrave; $ncart-owner /programlisting /informalexample para
[PHP-DOC] cvs: phpdoc /fr/language oop.xml
damsMon Feb 12 00:16:19 2001 EDT Modified files: /phpdoc/fr/language oop.xml Log: detailled stuff about members Index: phpdoc/fr/language/oop.xml diff -u phpdoc/fr/language/oop.xml:1.4 phpdoc/fr/language/oop.xml:1.5 --- phpdoc/fr/language/oop.xml:1.4 Mon Jan 22 03:55:59 2001 +++ phpdoc/fr/language/oop.xml Mon Feb 12 00:16:18 2001 @@ -102,8 +102,24 @@ Dans les fonctions d'une classe, la variable $this est eacute;gale agrave; l'objet de la classe. Vous pouvez utilisez la forme "$this-quelquechose" pour acceacute;der aux - fonctions ou aux variables de l'objet courant. + fonctions ou aux variables de l'objet courant. Aussi bien + depuis l'objet lui-mme que de l'exteacute;rieur, vous n'avez pas + besoin de literal$/literal pour acceacute;der aux + proprieacute;teacute;s d'un objet. /para + informalexample +programlisting role="php" +lt;?php +$ncart-owner = "chris"; // pas de '$' + +$ncart-$owner = "chris"; +// Ceci est invalide, car $ncart-$owner eacute;quivaut $ncart-"" + +$myvar = 'owner'; +$ncart-$myvar = "chris"; +// Ceci est valide, car $ncart-$owner eacute;quivaut $ncart-owner +/programlisting + /informalexample para Le constructeur est la fonction qui est appeleacute;e automatiquement par la classe lorsque vous creacute;ez