nlopess Sun Jul 11 05:32:52 2004 EDT
Added files:
/phpdoc/en/language/oop5 oop5-object-comparison.xml
oop5-paamayim-nekudotayim.xml
Removed files:
/phpdoc/en/language/oop5 oop5-paamayim-nekudotayim.php
Modified files:
/phpdoc/en/language oop.xml oop5.xml
/phpdoc/en/language/oop5 oop5-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 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.52 $ -->
+<!-- $Revision: 1.53 $ -->
<chapter id="language.oop">
- <title>Classes and Objects</title>
+ <title>Classes and Objects (PHP 4)</title>
<sect1 id="keyword.class">
<title><literal>class</literal></title>
@@ -964,8 +964,8 @@
</para>
</sect1>
- <sect1 id="language.oop.object-comparison-php4">
- <title>Comparing objects in PHP 4</title>
+ <sect1 id="language.oop.object-comparison">
+ <title>Comparing 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">
- <title>Comparing 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>
- <title>Example 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.2&r2=1.3&ty=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">
- <title>Classes and Objects</title>
+ <title>Classes and Objects (PHP 5)</title>
<sect1 id="op5.intro">
<title>Introduction</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>
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 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<sect1 id="oop5-decon">
<title>Constructors and Destructors</title>
<sect2 id="oop5-decon-constructor">
@@ -14,7 +14,7 @@
<simpara>
Parent constructors are not called implicitly. In order to run
a parent constructor, a call to
- <function>parent::__construct()</function> is required.
+ <function>parent::__construct</function> is required.
</simpara>
</note>
<example>
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
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<sect1 id="language.oop5.object-comparison">
<title>Comparing objects</title>
<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>
<title>Example 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>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
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
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
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
+++ phpdoc/en/language/oop5/oop5-paamayim-nekudotayim.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<sect1 id="oop5-paamayim-nekudotayim">
<title>::</title>
<para>
.
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
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
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->