mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Add output of __get()/__set() example; Fix title of __call() example; Mention that these methods are only invoked when the property/method does not exist in the class
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@163392 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
ec4be0547a
commit
20bf79e0d5
1 changed files with 32 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.21 $ -->
|
||||
<!-- $Revision: 1.22 $ -->
|
||||
<appendix id="migration5">
|
||||
<title>Migrating from PHP 4 to PHP 5</title>
|
||||
|
||||
|
@ -1308,7 +1308,9 @@ $object = new ClassName;
|
|||
<para>
|
||||
Both method calls and property accesses can be overloaded via the
|
||||
<function>__call</function>, <function>__get</function> and
|
||||
<function>__set</function> methods.
|
||||
<function>__set</function> methods. These methods will only be
|
||||
triggered when your object doesn't contain the property or method
|
||||
your're trying to access.
|
||||
</para>
|
||||
<example>
|
||||
<title>
|
||||
|
@ -1346,7 +1348,6 @@ class Setter {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
$foo = new Setter();
|
||||
$foo->n = 1;
|
||||
$foo->a = 100;
|
||||
|
@ -1356,9 +1357,36 @@ var_dump($foo);
|
|||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<screen role="php">
|
||||
<![CDATA[
|
||||
Setting [a] to 100
|
||||
OK!
|
||||
Getting [a]
|
||||
Returning: 100
|
||||
Setting [a] to 101
|
||||
OK!
|
||||
Getting [z]
|
||||
Nothing!
|
||||
Setting [z] to 1
|
||||
Not OK!
|
||||
object(Setter)#1 (2) {
|
||||
["n"]=>
|
||||
int(1)
|
||||
["x"]=>
|
||||
array(3) {
|
||||
["a"]=>
|
||||
int(101)
|
||||
["b"]=>
|
||||
int(2)
|
||||
["c"]=>
|
||||
int(3)
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>__get</function> example</title>
|
||||
<title><function>__call</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
|
Loading…
Reference in a new issue