[PHP-DOC] cvs: phpdoc /en/language oop.xml

2007-08-16 Thread Jakub Vrana
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.68&r2=1.69&diff_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 @@
 
-
+
  http://docbook.org/ns/docbook";>
   Classes and Objects (PHP 4)
 
@@ -7,7 +7,9 @@
class

 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 var and
+functions by function. A class is defined using the
+following syntax:


 


[PHP-DOC] cvs: phpdoc /en/language oop.xml /en/language/oop5 magic.xml

2007-03-24 Thread Jakub Vrana
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.66&r2=1.67&diff_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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -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.
   
   
   
-   The intended use of __sleep is to close any
-   database connections that object may have, committing pending
+   The intended use of __sleep 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.13&r2=1.14&diff_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 @@
 
-
+
  
   Magic Methods
   
@@ -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.


-The intended use of __sleep is to close any
-database connections that the object may have, commit pending
+The intended use of __sleep 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.


+The __sleep method should return the value to serialize
+(usually $this), otherwise &null; is serialized.
+   
+   
 Conversely, unserialize checks for the
 presence of a function with the magic name 
 __wakeup. 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

2006-04-27 Thread Jakub Vrana
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.65&r2=1.66&diff_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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -231,10 +231,11 @@

 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
-$cart or $another_cart later. Thus,
+written, it was unknown whether the object would be named
+$cart, $another_cart, or something
+else later. Thus,
 you cannot write $cart->items 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
 $this which can be read as 'my own' or 'current
 object'. Thus, '$this->items[$artnr] +=


[PHP-DOC] cvs: phpdoc /en/language oop.xml

2006-04-27 Thread Jakub Vrana
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.64&r2=1.65&diff_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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -394,7 +394,7 @@
 called when you create a new instance of a class with
 new. 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.

  


[PHP-DOC] cvs: phpdoc /en/language oop.xml

2005-07-22 Thread Jakub Vrana
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.63&r2=1.64&ty=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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -651,7 +651,7 @@
 
   

-The following information is valid for PHP 4 only. 
+The following information is valid for PHP >= 4 only. 

   
 


[PHP-DOC] cvs: phpdoc /en/language oop.xml

2005-07-12 Thread Ken Tossell
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.62&r2=1.63&ty=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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -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
 $this at all.

 


Re: [PHP-DOC] cvs: phpdoc /en/language oop.xml

2005-04-06 Thread Jakub Vrana
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


Re: [PHP-DOC] cvs: phpdoc /en/language oop.xml

2005-04-06 Thread Derick Rethans
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


[PHP-DOC] cvs: phpdoc /en/language oop.xml

2005-04-06 Thread Jakub Vrana
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.61&r2=1.62&ty=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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -389,28 +389,19 @@
   
Constructors
 
-   
-
- In PHP 3 and PHP 4 constructors behave differently. The PHP 4
- semantics are strongly preferred.
-
-   
-

 Constructors are functions in a class that are automatically
 called when you create a new instance of a class with
-new. 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).
+new. 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.

  

 
 
@@ -460,51 +448,6 @@
 @new.

 
-   
-
- In PHP 3, derived classes and constructors have a number of
- limitations. The following examples should be read carefully
- to understand these limitations.
- 
-   
-   
-   
-
-
-
-   
-
-   
-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.
-   
-   
-   
-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.
' in PHP 4. - - @@ -539,43 +478,27 @@ -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. - -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.
'. - - - 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. - - - There are no destructors in PHP 3 or PHP 4. You may use - register_shutdown_function instead - to simulate most effects of destructors. - - - Destructors are functions that are called automatically when an object is destroyed, either with unset or by simply going out of scope. There are no destructors -in PHP. +in PHP. You may use register_shutdown_function +instead to simulate most effects of destructors.

[PHP-DOC] cvs: phpdoc /en/language oop.xml

2005-03-09 Thread Damien Seguy
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.60&r2=1.61&ty=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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -101,7 +101,7 @@
 

 
- The name stdClass is used interally by
+ The name stdClass is used internally by
  Zend and is reserved. You cannot have a class named
  stdClass in PHP.
 
@@ -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 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 ->.  Thus, the names
-$cart->items and
+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 ->.  Thus, the
+names $cart->items and
 $another_cart->items name two different variables.
 Note that the variable is named $cart->items, not
 $cart->$items, that is, a variable name in PHP has
@@ -1133,8 +1133,8 @@
 
   
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.
   
   
Even in the cases where we have object composition, the same comparison


[PHP-DOC] cvs: phpdoc /en/language oop.xml

2005-02-14 Thread Jakub Vrana
vrana   Mon Feb 14 04:10:13 2005 EDT

  Modified files:  
/phpdoc/en/language oop.xml 
  Log:
  Constructors title is not 
  
http://cvs.php.net/diff.php/phpdoc/en/language/oop.xml?r1=1.59&r2=1.60&ty=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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -387,7 +387,7 @@
   
 
   
-   Constructors
+   Constructors
 

 


[PHP-DOC] cvs: phpdoc /en/language oop.xml

2005-02-07 Thread Sean Coates
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.58&r2=1.59&ty=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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -249,7 +249,7 @@
  The $this pseudo-variable is not usually defined if
  the method in which it is hosted is called statically. This is not,
  however, a strict rule: $this 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
  $this is that of the calling object. This is
  illustrated in the following example:
  


[PHP-DOC] cvs: phpdoc /en/language oop.xml

2005-01-28 Thread Sean Coates
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.57&r2=1.58&ty=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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -246,6 +246,62 @@
 

 
+ The $this pseudo-variable is not usually defined if
+ the method in which it is hosted is called statically. This is not,
+ however, a strict rule: $this is defined if a method is
+ called statically from within another object, and the value of
+ $this is that of the calling object. This is
+ illustrated in the following example:
+ 
+  
+ 
+  
+  &example.outputs;
+  
+
+  
+ 
+
+   
+
+   
+
 There are some nice functions to handle classes and objects. You might want
 to take a look at the Class/Object
 Functions.


[PHP-DOC] cvs: phpdoc /en/language oop.xml

2004-12-08 Thread Nuno Lopes
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.55&r2=1.56&ty=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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -16,22 +16,25 @@
 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

2004-12-07 Thread Sean Coates
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.54&r2=1.55&ty=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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -49,7 +49,9 @@

 
  You can NOT break up a class definition into
- multiple files, or multiple PHP blocks. The following will not work:
+ multiple files. You also can NOT break a class
+ definition into multiple PHP blocks, unless the break is within a method
+ declaration. The following will not work:
 
 
  
@@ -68,6 +70,26 @@
   
  
 
+
+ However, the following is allowed:
+
+
+ 
+  
+
+  
+ 
+

 



[PHP-DOC] cvs: phpdoc /en/language oop.xml

2004-09-17 Thread Jakub Vrana
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.53&r2=1.54&ty=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 @@
 
-
+
  
   Classes and Objects (PHP 4)
 
@@ -499,7 +499,7 @@
   
 
  
-   ::
+   Scope Resolution Operator (::)
 

 


[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

2004-07-11 Thread Nuno Lopes
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.52&r2=1.53&ty=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 @@
 
-
+
  
-  Classes and Objects
+  Classes and Objects (PHP 4)
 
   
class
@@ -964,8 +964,8 @@

   
 
-  
-   Comparing objects in PHP 4
+  
+   Comparing objects
   
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 @@

   
  
-
-  
-   Comparing objects in PHP 5
-   &warn.experimental;
-   
-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).
-   
-   
-When using the comparison operator (==), 
-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.
-   
-   
-On the other hand, when using the identity operator (===),
-object variables are identical if and only if they refer to the same
-instance of the same class.
-   
-   
-An example will clarify these rules.
-
- Example of object comparison in PHP 5
- 
-
- 
-
-This example will output:
-
-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
-
-   
-  
  
  
 
+
  
-  Classes and Objects
+  Classes and Objects (PHP 5)
 
   
Introduction
@@ -12,10 +12,7 @@
 
   &language.oop5.oop5-decon;
   &language.oop5.oop5-visibility;
-  
+  &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;
 
  
http://cvs.php.net/diff.php/phpdoc/en/language/oop5/oop5-decon.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/language/oop5/oop5-decon.xml
diff -u phpdoc/en/language/oop5/oop5-decon.xml:1.1 
phpdoc/en/language/oop5/oop5-decon.xml:1.2
--- phpdoc/en/language/oop5/oop5-decon.xml:1.1  Sat Jul 10 15:30:37 2004
+++ phpdoc/en/language/oop5/oop5-decon.xml  Sun Jul 11 05:32:52 2004
@@ -1,5 +1,5 @@
 
-
+
  
   Constructors and Destructors
   
@@ -14,7 +14,7 @@
  
   Parent constructors are not called implicitly.  In order to run
   a parent constructor, a call to
-  parent::__construct() is required.
+  parent::__construct is required.
  
 
 

http://cvs.php.net/co.php/phpdoc/en/language/oop5/oop5-object-comparison.xml?r=1.1&p=1
Index: phpdoc/en/language/oop5/oop5-object-comparison.xml
+++ phpdoc/en/language/oop5/oop5-object-comparison.xml


  
   Comparing objects
   
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).
   
   
When using the comparison operator (==), 
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.
   
   
On the other hand, when using the identity operator (===),
object variables are identical if and only if they refer to the same
instance of the same class.
   
   
An example will clarify these rules.

 Example of object comparison in PHP 5
 

 

This example will output:

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

   
  
 


http://cvs.php.net/co.php/phpdoc/en/language/oop5/oop5-paamayim-nekudotayim.xml?r=1.1&p=1
Index: phpdoc/en/language/oop5/oop5-paamayim-nekudotayim.xml
+

[PHP-DOC] cvs: phpdoc /en/language oop.xml

2004-05-23 Thread Jakub Vrana
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.51&r2=1.52&ty=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 @@
 
-
+
  
   Classes and Objects
 
@@ -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

2003-12-21 Thread Stefan Walk
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 @@
 
-
+
  
   Classes and Objects
 
@@ -114,12 +114,13 @@
 
 

[PHP-DOC] cvs: phpdoc /en/language oop.xml

2003-11-12 Thread Sara Golemon
pollita Wed Nov 12 23:53:14 2003 EDT

  Modified files:  
/phpdoc/en/language oop.xml 
  Log:
  Adapt example to not reflect non-existant namespaces.
  
Index: phpdoc/en/language/oop.xml
diff -u phpdoc/en/language/oop.xml:1.45 phpdoc/en/language/oop.xml:1.46
--- phpdoc/en/language/oop.xml:1.45 Tue Sep 30 04:40:06 2003
+++ phpdoc/en/language/oop.xml  Wed Nov 12 23:53:14 2003
@@ -1,5 +1,5 @@
 
-
+
  
   Classes and Objects
 
@@ -1159,12 +1159,12 @@
 When using the comparison operator (==), 
 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.
+instances of the same class.


 On the other hand, when using the identity operator (===),
 object variables are identical if and only if they refer to the same
-instance of the same class (in a particular namespace).
+instance of the same class.


 An example will clarify these rules.
@@ -1196,22 +1196,18 @@
 }
 }
 
-namespace Other {
-
-class Flag {
-var $flag;
+class OtherFlag {
+var $flag;
 
-function Flag($flag=true) {
-$this->flag = $flag;
-}
+function OtherFlag($flag=true) {
+$this->flag = $flag;
 }
-
 }
 
 $o = new Flag();
 $p = new Flag();
 $q = $o;
-$r = new Other::Flag();
+$r = new OtherFlag();
 
 echo "Two instances of the same class\n";
 compareObjects($o, $p);
@@ -1219,7 +1215,7 @@
 echo "\nTwo references to the same instance\n";
 compareObjects($o, $q);
 
-echo "\nInstances of similarly named classes in different namespaces\n";
+echo "\nInstances of two different classes\n";
 compareObjects($o, $r);
 ?>
 ]]>
@@ -1239,7 +1235,7 @@
 o1 === o2 : TRUE
 o1 !== o2 : FALSE
 
-Instances of similarly named classes in different namespaces
+Instances of two different classes
 o1 == o2 : FALSE
 o1 != o2 : TRUE
 o1 === o2 : FALSE


[PHP-DOC] cvs: phpdoc /en/language oop.xml

2003-06-18 Thread Derick Rethans
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 @@
 
-
+
  
   Classes and Objects
 
@@ -8,7 +8,8 @@

 A class is a collection of variables and functions working with
 these variables.  A class is defined using the following syntax:
- 
+   
+   
 
  
 
+  
+ 
+
+   
+
+   
+The following cautionary notes are valid for PHP 4.
+   
 
+   
 
  The name stdClass is used interally by
  Zend and is reserved. You cannot have a class named
  stdClass in PHP.
 
+   
 
+   
 
   The function names __sleep and
   __wakeup 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.
 
+   
 
+   
 
   PHP reserves all function names starting with __ as magical.
   It is recommended that you do not use function names with
@@ -74,16 +103,15 @@
 

 
-   
-
- In PHP 4, only constant initializers for var
- 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, only constant initializers for var
+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).
+   
+   
+
 
- 
-
-   
+
+   
 

 Classes are types, that is, they are blueprints for actual
@@ -137,29 +164,29 @@

  

-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 $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.



-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 ->. 
-Thus, the names $cart->items and $another_cart->items
-name two different variables. Note that the variable is
-named $cart->items, not $cart->$items, that is, a
-variable name in PHP has only a single dollar sign.
+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 ->.  Thus, the names
+$cart->items and
+$another_cart->items name two different variables.
+Note that the variable is named $cart->items, not
+$cart->$items, that is, a variable name in PHP has
+only a single dollar sign.

 

@@ -182,17 +209,19 @@

 

-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 $cart or
-$another_cart later. Thus, you cannot write $cart->items within
-the Cart class itself. Instead, in order to be able to access it's own
-functions and variables from within a

[PHP-DOC] cvs: phpdoc /en/language oop.xml

2003-06-13 Thread Derick Rethans
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 @@
 
-
+
  
   Classes and Objects
 
@@ -489,7 +489,7 @@
 

 
- The following is valid for PHP 4 only.
+ The following is valid for PHP 4 and later only.
 

 



-- 
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

2003-04-05 Thread Jesus M. Castagnetto
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 @@
 
-
+
  
   Classes and Objects
 
@@ -936,16 +936,14 @@

   
 
-  
+  
Comparing objects in PHP 4
-
   
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 (===).
   
-  
   
If we were to execute the code in the example below:

@@ -1084,6 +1082,105 @@
 o1 !== o2 : TRUE

   
+ 
+
+  
+   Comparing objects in PHP 5
+   &warn.experimental;
+   
+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).
+   
+   
+When using the comparison operator (==), 
+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.
+   
+   
+On the other hand, when using the identity operator (===),
+object variables are identical if and only if they refer to the same
+instance of the same class (in a particular namespace).
+   
+   
+An example will clarify these rules.
+
+ Example of object comparison in PHP 5
+ 
+
+ 
+
+This example will output:
+
+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
+
+   
  
  
  



-- 
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

2003-04-01 Thread Derick Rethans
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 @@
 
-
+
  
   Classes and Objects
 
@@ -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 Flag objects.
-   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
-
+   
 Compound object comparisons in PHP 4
 
 

[PHP-DOC] cvs: phpdoc /en/language oop.xml /en/reference/gmp/functions gmp-gcdext.xml /entities global.ent /images diophantine-equation.png

2003-03-31 Thread Jesus M. Castagnetto
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 @@
 
-
+
  
   Classes and Objects
 
@@ -774,7 +774,7 @@
 {
 echo "",$this->name;
 }
-   
+ 
 function setName($name)
 {
 $this->name = $name;
@@ -935,6 +935,167 @@
 

   
+
+  
+   Comparing objects in PHP 4
+
+  
+   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 (===).
+  
+  
+  
+   If we were to execute the code in the example below:
+   
+Example of object comparison in PHP 4
+
+
+
+   
+   We will see:
+   
+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
+   
+   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.
+  
+  
+   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 Flag objects.
+   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
+
+Compound object comparisons in PHP 4
+
+
+
+   
+   Which gives the expected output:
+   
+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
+   
+  
+ 
  
  
 
+
 
   

@@ -17,6 +17,45 @@
  Calculates g, s, and t, such that a*s + b*t = g =
  gcd(a,b), where gcd is the greatest common divisor. Returns
  an array with respective elements g, s and t.
+
+
+ This function can be used to solve linear Diophantine equations in two
+ variables. These are equations that allow only integer solutions and have the 
form:
+ 
+  a*x + b*y = c
+  
+  
+  For more information, go to the "Diophantine 
+   Equation" page at MathWorld
+
+
+ 
+  Solving a linear Diophantine equation
+  
+
+  
+ 
 

   
Index: phpdoc/entities/global.ent
diff -u phpdoc/entities/global.ent:1.86 phpdoc/entities/global.ent:1.87
--- phpdoc/entities/global.ent:1.86 Sun Mar 30 19:53:18 2003
+++ phpdoc/entities/global.ent  Tue Apr  1 01:39:54 2003
@@ -1,6 +1,6 @@
 

[PHP-DOC] cvs: phpdoc /en/language oop.xml references.xml

2002-06-10 Thread Markus Fischer

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 @@
 
-
+
  
   Classes and Objects
 
@@ -343,6 +343,12 @@
 ]]>
 

+
+   
+You also can use the @ operator to
+mute errors occuring in the constructor, e.g.
+@new.
+   
 

 
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 @@
 
-
+
  
   References Explained
 
@@ -62,6 +62,13 @@
  $this 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.
+ 
+ 
+  While you can use the @ operator to
+  mute any errors in the constructor when using it as
+  @new, this does not work when using the
+  &new statement. This is a limitation of the Zend
+  Engine and will therefore result in a parser error.
  







[PHP-DOC] cvs: phpdoc /en/language oop.xml

2002-06-10 Thread Markus Fischer

mfischerMon Jun 10 04:43:11 2002 EDT

  Modified files:  
/phpdoc/en/language oop.xml 
  Log:
  - Document that order of class definition is important (closes #13165).
  # Though the zend engine CAN handle class definitions not in the right order
  # this is not always true, especially when extending classes which extend
  # classes.  See the report.
  
  
Index: phpdoc/en/language/oop.xml
diff -u phpdoc/en/language/oop.xml:1.34 phpdoc/en/language/oop.xml:1.35
--- phpdoc/en/language/oop.xml:1.34 Wed May 15 16:41:17 2002
+++ phpdoc/en/language/oop.xml  Mon Jun 10 04:43:11 2002
@@ -1,5 +1,5 @@
 
-
+
  
   Classes and Objects
 
@@ -255,6 +255,25 @@
 

 
+   
+This is also called a "parent-child" relationship. You create a class,
+parent, and use extends to create a new class
+based on the parent class: the child class. You can
+even use this new child class and create another class based on this child
+class.
+   
+   
+
+ Classes must be defined before they are used! If you want the class
+ Named_Cart to extend the class
+ Cart, you will have to define the class
+ Cart first. If you want to create another class called
+ Yellow_named_cart based on the class
+ Named_Cart you have to define
+ Named_Cart first. To make it short: the order in which
+ the classes are defined is important.
+
+   
   
 
   





[PHP-DOC] cvs: phpdoc /en/language oop.xml

2002-05-15 Thread Thomas Schoefbeck

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 @@
 
-
+
  
   Classes and Objects
 
@@ -110,6 +110,7 @@
 /* etc. . . */
 }
 }
+?>
 ]]>
  
 





[PHP-DOC] cvs: phpdoc /en/language oop.xml

2002-04-01 Thread Sander Roobol

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 @@
 
-
+
  
   Classes and Objects
 
@@ -190,6 +190,14 @@
 array' or 'add $num to the $artnr counter of the items array
 within the current object'.

+
+   
+
+There are some nice functions to handle classes and objects. You might want
+to take a look at the Class/Object
+Functions
+
+   
   
   
   





[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-10-27 Thread Leszek Krupinski

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 @@
 
-
+
  
   Classes and Objects
 
@@ -169,13 +169,13 @@
 

 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->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->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, unserialize checks for the
presence of a function with the magic name 
__wakeup. If present, this function can
-   reconstruct any ressources that object may have.
+   reconstruct any resources that object may have.
   
   
   





[PHP-DOC] cvs: phpdoc /en/language oop.xml /fr/language oop.xml /hu/language oop.xml /it/language oop.xml /ja/language oop.xml

2001-09-08 Thread Hojtsy Gabor

gobaSat Sep  8 12:54:54 2001 EDT

  Modified files:  
/phpdoc/fr/language oop.xml 
/phpdoc/it/language oop.xml 
/phpdoc/ja/language oop.xml 
/phpdoc/hu/language oop.xml 
/phpdoc/en/language oop.xml 
  Log:
  Changing bad 
  
keyword.paamayim_nekudotayim
  
  ID to
  
keyword.paamayim-nekudotayim
  
  As _ should not be used in IDs! Anybody, who
  added this ID, please read the README 10 times (at least).
  Hope I won't brake any files.
  
  
  
Index: phpdoc/fr/language/oop.xml
diff -u phpdoc/fr/language/oop.xml:1.13 phpdoc/fr/language/oop.xml:1.14
--- phpdoc/fr/language/oop.xml:1.13 Wed Aug  8 05:47:25 2001
+++ phpdoc/fr/language/oop.xml  Sat Sep  8 12:54:52 2001
@@ -1,4 +1,4 @@
-
+
  
   Les classes et les objets
   
@@ -349,7 +349,7 @@
 Il n'y a pas de destructeurs en PHP.

   
- 
+ 
Opérateur ::

 
Index: phpdoc/it/language/oop.xml
diff -u phpdoc/it/language/oop.xml:1.5 phpdoc/it/language/oop.xml:1.6
--- phpdoc/it/language/oop.xml:1.5  Sat Jul  7 18:25:28 2001
+++ phpdoc/it/language/oop.xml  Sat Sep  8 12:54:53 2001
@@ -390,7 +390,7 @@

   
 
- 
+ 
::
 

Index: phpdoc/ja/language/oop.xml
diff -u phpdoc/ja/language/oop.xml:1.10 phpdoc/ja/language/oop.xml:1.11
--- phpdoc/ja/language/oop.xml:1.10 Sun Aug 12 20:33:49 2001
+++ phpdoc/ja/language/oop.xml  Sat Sep  8 12:54:53 2001
@@ -376,7 +376,7 @@

   
 
- 
+ 
::
 

Index: phpdoc/hu/language/oop.xml
diff -u phpdoc/hu/language/oop.xml:1.5 phpdoc/hu/language/oop.xml:1.6
--- phpdoc/hu/language/oop.xml:1.5  Thu Aug 30 11:42:58 2001
+++ phpdoc/hu/language/oop.xml  Sat Sep  8 12:54:53 2001
@@ -1,5 +1,5 @@
 
-
+
 
  
   Osztályok, objektumok
@@ -445,7 +445,7 @@
 
   
 
-  
+  
::
 

Index: phpdoc/en/language/oop.xml
diff -u phpdoc/en/language/oop.xml:1.26 phpdoc/en/language/oop.xml:1.27
--- phpdoc/en/language/oop.xml:1.26 Mon Aug 20 12:25:36 2001
+++ phpdoc/en/language/oop.xml  Sat Sep  8 12:54:53 2001
@@ -1,5 +1,5 @@
 
-
+
  
   Classes and Objects
 
@@ -413,7 +413,7 @@

   
 
- 
+ 
::
 






[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-08-20 Thread Hojtsy Gabor

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 @@
 
-
+
  
   Classes and Objects
 
@@ -710,12 +710,12 @@
 
 function echoName()
 {
-echo "
",$this->Name; +echo "
",$this->name; } function setName($name) { -$this->Name = $name; +$this->name = $name; } } @@ -741,7 +741,7 @@ set in constructor set in constructor */ -$bar2 =& new foo('set in constructor'); +$bar2 =& new Foo('set in constructor'); $bar2->echoName(); $globalref[1]->echoName(); @@ -761,7 +761,7 @@ return a reference by default, instead it returns a copy. - 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 @@ // 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

2001-08-20 Thread Hojtsy Gabor

gobaMon Aug 20 11:54:40 2001 EDT

  Modified files:  
/phpdoc/en/language oop.xml 
  Log:
  Class names start with an uppercased letters...
  
  
Index: phpdoc/en/language/oop.xml
diff -u phpdoc/en/language/oop.xml:1.24 phpdoc/en/language/oop.xml:1.25
--- phpdoc/en/language/oop.xml:1.24 Mon Aug 20 09:37:41 2001
+++ phpdoc/en/language/oop.xml  Mon Aug 20 11:54:40 2001
@@ -1,5 +1,5 @@
 
-
+
  
   Classes and Objects
 
@@ -504,7 +504,7 @@
   
You may find yourself writing code that refers to
variables and functions in base classes. This is
-   particularly &true; if your derived class is a refinement
+   particularly true if your derived class is a refinement
or specialisation of code in your base class. 
   
   
@@ -534,7 +534,7 @@
 {
 function example()
 {
-echo "I am B::example and provide additional functionality().
\n"; +echo "I am B::example() and provide additional functionality.
\n"; parent::example(); } } @@ -617,9 +617,9 @@ include("classa.inc"); $s = implode("", @file("store")); - unserialize($s); + $a = unserialize($s); - // now use the function show_one of the $a object. + // now use the function show_one() of the $a object. $a->show_one(); @@ -695,9 +695,9 @@ -class foo +class Foo { -function foo($name) +function Foo($name) { // create a reference inside the global array $globalref global $globalref; @@ -732,7 +732,7 @@ -$bar1 = new foo('set in constructor'); +$bar1 = new Foo('set in constructor'); $bar1->echoName(); $globalref[0]->echoName(); @@ -806,18 +806,18 @@ -class a +class A { -function a($i) +function A($i) { $this->value = $i; // try to figure out why we do not need a reference here -$this->b = new b($this); +$this->b = new B($this); } function createRef() { -$this->c = new b($this); +$this->c = new B($this); } function echoValue() @@ -827,9 +827,9 @@ } -class b +class B { -function b(&$a) +function B(&$a) { $this->a = &$a; } @@ -842,7 +842,7 @@ // try to undestand why using a simple copy here would yield // in an undesired result in the *-marked line -$a =& new a(10); +$a =& new A(10); $a->createRef(); $a->echoValue(); @@ -857,12 +857,12 @@ /* output: -class a: 10 -class b: 10 -class b: 10 -class a: 11 -class b: 11 -class b: 11 +class A: 10 +class B: 10 +class B: 10 +class A: 11 +class B: 11 +class B: 11 */

[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-08-20 Thread Hojtsy Gabor

gobaMon Aug 20 09:37:41 2001 EDT

  Modified files:  
/phpdoc/en/language oop.xml 
  Log:
  Please use 4 (four!) spaces for identation, many, many
  WS ONLY FIXES.
  
  
Index: phpdoc/en/language/oop.xml
diff -u phpdoc/en/language/oop.xml:1.23 phpdoc/en/language/oop.xml:1.24
--- phpdoc/en/language/oop.xml:1.23 Mon Aug 20 09:34:06 2001
+++ phpdoc/en/language/oop.xml  Mon Aug 20 09:37:41 2001
@@ -1,5 +1,5 @@
 
-
+
  
   Classes and Objects
 
@@ -310,18 +310,18 @@
 
 class A
 {
-  function A()
-  {
-echo "I am the constructor of A.
\n"; - } +function A() +{ + echo "I am the constructor of A.
\n"; +} } class B extends A { - function C() - { -echo "I am a regular function.
\n"; - } +function C() +{ +echo "I am a regular function.
\n"; +} } // no constructor is being called in PHP 3. @@ -347,24 +347,24 @@ class A { - function A() - { -echo "I am the constructor of A.
\n"; - } - - function B() - { -echo "I am a regular function named B in class A.
\n"; -echo "I am not a constructor in A.
\n"; - } +function A() +{ +echo "I am the constructor of A.
\n"; +} + +function B() +{ +echo "I am a regular function named B in class A.
\n"; +echo "I am not a constructor in A.
\n"; +} } class B extends A { - function C() - { -echo "I am a regular function.
\n"; - } +function C() +{ +echo "I am a regular function.
\n"; +} } // This will call B() as a constructor. @@ -433,19 +433,19 @@ class A { - function example() - { -echo "I am the original function A::example().
\n"; - } +function example() +{ +echo "I am the original function A::example().
\n"; +} } class B extends A { - function example() - { -echo "I am the redefined function B::example().
\n"; -A::example(); - } +function example() +{ +echo "I am the redefined function B::example().
\n"; +A::example(); +} } // there is no object of class A. @@ -524,19 +524,19 @@ class A { - function example() - { -echo "I am A::example() and provide basic functionality.
\n"; - } +function example() +{ +echo "I am A::example() and provide basic functionality.
\n"; +} } class B extends A { - function example() - { -echo "I am B::example and provide additional functionality().
\n"; -parent::example(); - } +function example() +{ +echo "I am B::example and provide additional functionality().
\n"; +parent::example(); +} } $b = new B; @@ -594,12 +594,12 @@ classa.inc: class A { -var $one = 1; + var $one = 1; -function show_one() -{ - echo $this->one; -} + function show_one() + { + echo $this->one; + } } page1.php: @@ -750,9 +750,9 @@ set in constructor set in constructor */ - - - + + + Apparently there is no difference, but in fact there is a very significant one: $bar1 and

[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-08-20 Thread Hojtsy Gabor

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 @@
 
-
+
  
   Classes and Objects
 
@@ -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);  
 
@@ -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 @@


 Destructors are functions that are called automatically
-when a variable is destroyed, either with unset
+when an object is destroyed, either with unset
 or by simply going out of scope. There are no destructors
 in PHP.






[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-08-15 Thread Hojtsy Gabor

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 @@
-
+
  
   Classes and Objects
 
@@ -303,7 +303,7 @@
 
 class B extends A {
   function C() {
-"I am a regular function.
\n"; +echo "I am a regular function.
\n"; } }

[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-08-02 Thread Hojtsy Gabor

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 @@
   
   
   
-   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 session_register("a"), you should
include the file classa.inc on all of your
pages, not only page1.php and page2.php.





[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-06-27 Thread Daniel Beckham

danbeck Wed Jun 27 08:11:31 2001 EDT

  Modified files:  
/phpdoc/en/language oop.xml 
  Log:
  adding extra example for issue in bug #10022
  
Index: phpdoc/en/language/oop.xml
diff -u phpdoc/en/language/oop.xml:1.14 phpdoc/en/language/oop.xml:1.15
--- phpdoc/en/language/oop.xml:1.14 Fri May 18 14:44:37 2001
+++ phpdoc/en/language/oop.xml  Wed Jun 27 08:11:31 2001
@@ -82,6 +82,7 @@
 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. */
@@ -89,6 +90,7 @@
 var $todays_date;
 var $name;
 var $owner;
+var $items;
 
 function Cart() {
 $this->todays_date = date("Y-m-d");





[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-05-18 Thread Kristian Köhntopp

kk  Fri May 18 05:44:37 2001 EDT

  Modified files:  
/phpdoc/en/language oop.xml 
  Log:
  - Some clarifications.
  - Normalized spelling of product names (PHP 3 and PHP 4)
to go with the rest of our docs.
  
  
  

Index: phpdoc/en/language/oop.xml
diff -u phpdoc/en/language/oop.xml:1.13 phpdoc/en/language/oop.xml:1.14
--- phpdoc/en/language/oop.xml:1.13 Fri May 18 00:47:01 2001
+++ phpdoc/en/language/oop.xml  Fri May 18 05:44:37 2001
@@ -43,7 +43,7 @@
 

 
- The following cautionary note are valid for PHP4.
+ The following cautionary notes are valid for PHP 4.
 
 
 
@@ -103,7 +103,7 @@

 Classes are types, that is, they are blueprints for actual
 variables. You have to create a variable of the desired type with
-the new operator.
+the new operator.

  

@@ -126,18 +126,20 @@


 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 ->. Thus, the names $cart->items and 
-$another_cart->items name two different variables. Note
-that the variable is named $cart->items, not
-$cart->$items, that is, a variable name in PHP has only a
-single dollar sign.
+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 ->. 
+Thus, the names $cart->items and $another_cart->items
+name two different variables. Note that the variable is
+named $cart->items, not $cart->$items, that is, a
+variable name in PHP has only a single dollar sign.

 

@@ -156,11 +158,11 @@

 

-Within a class, you do not know under which name the object will
+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 $cart or
 $another_cart later. Thus, you cannot write $cart->items within
-the Cart class. Instead, in order to be able to access it's own
+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
@@ -225,22 +227,24 @@
 

 
- In PHP3 and PHP4 constructors behave differently. The PHP4
+ In PHP 3 and PHP 4 constructors behave differently. The PHP 4
  semantics are strongly preferred.
 

 

 Constructors are functions in a class that are automatically
-called when you create a new instance of a class. In PHP3, a
+called when you create a new instance of a class with
+new. In PHP 3, a
 function becomes a constructor when it has the same name as 
-the class. In PHP4, a function becomes a constructor, when
-it has the same name as the class it is defined in.
+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).

  

 
-// Works in PHP3 and PHP4.
+// Works in PHP 3 and PHP 4.
 class Auto_Cart extends Cart {
 function Auto_Cart () {
 $this->add_item ("10", 1);
@@ -253,7 +257,7 @@
 This defines a class Auto_Cart that is a Cart plus a constructor
 which initializes the cart with one item of article number "10"
 each time a new Auto_Cart is being made with "new". Constructors
-can also take arguments and these arguments can be optional, which
+can take arguments and these arguments can be optional, which
 makes them much more useful. To be able to still use the class
 without parameters, all parameters to constructors should be
 made optional by providing default values.
@@ -261,7 +265,7 @@
  

 
-// Works in PHP3 and PHP4.
+// Works in PHP 3 and PHP 4.
 class Constructor_Cart extends Cart {
 function Constructor_Cart ($item = "10", $num =

Re: [PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-05-18 Thread eschmid+sic

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:
> > 
> >   
> >
> > The following information is valid for PHP4 only. In
> > PHP3, an
> >
> >   
> 
> 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

2001-05-18 Thread Kristian Köhntopp

kk  Fri May 18 00:47:01 2001 EDT

  Modified files:  
/phpdoc/en/language oop.xml 
  Log:
  Completed the unfinished sentence.
  
  
Index: phpdoc/en/language/oop.xml
diff -u phpdoc/en/language/oop.xml:1.12 phpdoc/en/language/oop.xml:1.13
--- phpdoc/en/language/oop.xml:1.12 Thu May 17 16:05:01 2001
+++ phpdoc/en/language/oop.xml  Fri May 18 00:47:01 2001
@@ -511,10 +511,19 @@
  
   Serializing objects - objects in sessions
 
+  
+   
+In PHP3, objects will lose their class association
+throughout the process of serialization and unserialization. 
+The resulting variable is of type object, but has no class
+and no methods, thus it is pretty useless (it has become
+just like an array with a funny syntax).
+   
+  
+
   

-The following information is valid for PHP4 only. In
-PHP3, an 
+The following information is valid for PHP4 only. 

   
 





Re: [PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-05-18 Thread Kristian Köhntopp

Daniel Beckham wrote:
> It looks like you might have truncated this sentence in the
> language.oop.serialization section of oop.xml:
> 
>   
>
> The following information is valid for PHP4 only. In
> PHP3, an
>
>   

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

2001-05-17 Thread Daniel Beckham

It looks like you might have truncated this sentence in the
language.oop.serialization section of oop.xml:

  
   
The following information is valid for PHP4 only. In
PHP3, an
   
  


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

2001-05-17 Thread Daniel Beckham

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.
>
>




[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-05-17 Thread Kristian Köhntopp

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.

 
+   
+
+ The following cautionary note are valid for PHP4.
+
+
+
+ The name stdClass is used interally by
+ Zend and is reserved. You cannot have a class named
+ stdClass in PHP.
+
+
+
+  The function names __sleep and
+  __wakeup 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.
+
+
+
+  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.
+
+   
+

 
  In PHP 4, only constant initializers for var
- 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).
 
 
  
@@ -80,20 +108,86 @@
  

 
-$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);
 

  
+   
+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 an object $cart of the class Cart. The function
-add_item() of that object is being called to add 1 item of article
-number 10 to the cart.   Classes can be extensions of
-other classes. The extended or derived class has all variables and
-functions of the base class and what you add in the extended
-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 ->. Thus, the names $cart->items and 
+$another_cart->items name two different variables. Note
+that the variable is named $cart->items, not
+$cart->$items, that is, a variable name in PHP has only a
+single dollar sign.

+
+   
+
+// 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);  
+
+   
+
+   
+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->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
+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'.
+   
+  
+  
+  
+   extends
+
+   
+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

[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-03-09 Thread Torben Wilson

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 @@
  
References inside the constructor

-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.
  
 
  





[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-03-09 Thread André Langhorst

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 @@

   
   
- 
-   references inside the constructor
+ 
+   References inside the constructor

 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.
  
 
  





[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-03-09 Thread André Langhorst

andre   Fri Mar  9 14:29:02 2001 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.8 phpdoc/en/language/oop.xml:1.9
--- phpdoc/en/language/oop.xml:1.8  Fri Mar  9 13:45:32 2001
+++ phpdoc/en/language/oop.xml  Fri Mar  9 14:29:02 2001
@@ -209,7 +209,7 @@
 function foo($name) {
 // create a reference inside the global array $globalref
 global $globalref;
-   $globalref[] = &$this;
+   $globalref[] = &$this;
 // set name to passed value
 $this->setName($name);
// and put it out
@@ -217,7 +217,7 @@
 }
 
 function echoName() {
-echo "",$this->Name;
+echo "
",$this->Name; } function setName($name) { @@ -226,11 +226,12 @@ } - + + Let us check out if there is a difference between $bar1 which has been created using the copy = operator - and $bar2 which has been created using the reference =& operator... - + and $bar2 which has been created using the reference +=& operator... + @@ -244,7 +245,7 @@ set in constructor set in constructor */ -$bar2 =& new foo('set in constructor'); +$bar2 =& new foo('set in constructor'); $bar2->echoName(); $globalref[1]->echoName(); @@ -255,7 +256,7 @@ - + Apparently there is no difference, but in fact there is a very significant one: $bar1 and $globalref[0] are _NOT_ referenced, they are NOT the same variable. @@ -270,7 +271,7 @@ To prove what is written above let us watch the code below. - + @@ -300,7 +301,7 @@ - + Another final example, try to understand it. @@ -319,26 +320,26 @@ } function echoValue() { -echo "","class ",get_class($this),': ',$this->value; +echo "
","class ",get_class($this),': ',$this->value; } } class b { -function b(&$a) { -$this->a = &$a; +function b(&$a) { +$this->a = &$a; } function echoValue() { -echo "","class ",get_class($this),': ',$this->a->value; +echo "
","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 =& new a(10); $a->createRef(); $a->echoValue(); @@ -361,8 +362,8 @@ class b: 11 */ - - + +

[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-03-09 Thread André Langhorst

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 @@
 }   
 }
 }
-?>
+?>
  
 

@@ -195,6 +195,176 @@
  

   
+  
+ 
+   references inside the constructor
+   
+Creating references within the constructor can lead to confusing results. This 
+tutorial like section helps you
+to avoid problems.
+ 
+
+ 
+
+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 "",$this->Name;
+}
+   
+   function setName($name) {
+   $this->Name = $name;
+}
+}
+
+   
+
+   
+   Let us check out if there is a difference between $bar1 which 
+has been created using the copy = operator
+   and $bar2 which has been created using the reference 
+=& operator...
+   
+
+
+ 
+   
+$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 */
+
+
+   
+   
+   
+Apparently there is no difference, but in fact there is a very significant one:
+$bar1 and $globalref[0] 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.
+   
+ 
+ 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).
+ 
+
+To prove what is written above let us watch the code below.
+   
+
+   
+ 
+// 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 */
+
+  
+  
+   
+   
+   Another final example, try to understand it.
+   
+   
+ 
+
+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 "","class ",get_class($this),': ',$this->value;
+}
+}
+
+
+class b  {
+
+function b(&$a) {
+$this->a = &$a;
+}
+
+   function echoValue() {
+echo "","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
+class b: 10
+class a: 11
+class b: 11
+class b: 11
+*/
+  
+  
+
+
+
  
  
  





[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-02-22 Thread Torben Wilson

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.

-   
-   In PHP 4, only constant initializers for var
-   variables are allowed. Use constructors for non-constant initializers.
-   
+
+   
+
+ In PHP 4, only constant initializers for var
+ variables are allowed. Use constructors for non-constant
+ initializers.  
+
+
+ 
+/* 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. . . */
+}
+}
+ 
+
+   
+

 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 @@
  

 
- $cart = new Cart;
- $cart->add_item("10", 1);
+$cart = new Cart;
+$cart->add_item("10", 1);
 

  





[PHP-DOC] cvs: phpdoc /en/language oop.xml

2001-02-09 Thread Chris Newbill

cnewbillFri Feb  9 11:41:09 2001 EDT

  Modified files:  
/phpdoc/en/language oop.xml 
  Log:
  Added the following lines:
  
  Both in and outside of the object you do not need a $ when accessing an
  object's properties.
  
  Also a code snippet to reference the previous statement.
  
  
Index: phpdoc/en/language/oop.xml
diff -u phpdoc/en/language/oop.xml:1.5 phpdoc/en/language/oop.xml:1.6
--- phpdoc/en/language/oop.xml:1.5  Mon Oct  2 02:37:53 2000
+++ phpdoc/en/language/oop.xml  Fri Feb  9 11:41:08 2001
@@ -99,8 +99,24 @@

 Within functions of a class the variable $this means this
 object. You have to use $this->something to access any variable or
-function named something within your current object.
+function named something within your current object.  Both in and
+outside of the object you do not need a $ when accessing an object's
+properties.

+
+   
+
+$ncart->owner  = "chris"; // no $
+
+$ncart->$owner = "chris";
+// this is invalid because $ncart->$owner = $ncart->""
+
+$myvar = 'owner';
+$ncart->$myvar = "chris";  
+// this is valid because $ncart->$myvar = $ncart->owner
+
+   
+

 Constructors are functions in a class that are automatically
 called when you create a new instance of a class. A function