mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Adapt example to not reflect non-existant namespaces.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@144249 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
d0fefa8d94
commit
558a383fac
1 changed files with 10 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.45 $ -->
|
||||
<!-- $Revision: 1.46 $ -->
|
||||
<chapter id="language.oop">
|
||||
<title>Classes and Objects</title>
|
||||
|
||||
|
@ -1159,12 +1159,12 @@ o1 !== o2 : TRUE
|
|||
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.
|
||||
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 (in a particular namespace).
|
||||
instance of the same class.
|
||||
</para>
|
||||
<para>
|
||||
An example will clarify these rules.
|
||||
|
@ -1196,22 +1196,18 @@ class Flag {
|
|||
}
|
||||
}
|
||||
|
||||
namespace Other {
|
||||
class OtherFlag {
|
||||
var $flag;
|
||||
|
||||
class Flag {
|
||||
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 @@ compareObjects($o, $p);
|
|||
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 : FALSE
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue