From 20bf79e0d5a40fe1213ef7a6ff1774dbe41912a2 Mon Sep 17 00:00:00 2001 From: Adam Trachtenberg Date: Thu, 15 Jul 2004 15:48:44 +0000 Subject: [PATCH] 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 --- appendices/migration5.xml | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/appendices/migration5.xml b/appendices/migration5.xml index 7bf3fdc468..6161abc4a1 100755 --- a/appendices/migration5.xml +++ b/appendices/migration5.xml @@ -1,5 +1,5 @@ - + Migrating from PHP 4 to PHP 5 @@ -1308,7 +1308,9 @@ $object = new ClassName; Both method calls and property accesses can be overloaded via the __call, __get and - __set methods. + __set methods. These methods will only be + triggered when your object doesn't contain the property or method + your're trying to access. @@ -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 + <function>__call</function> example