amt Thu Jul 15 11:48:45 2004 EDT
Modified files: /phpdoc/en/appendices migration5.xml Log: 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 http://cvs.php.net/diff.php/phpdoc/en/appendices/migration5.xml?r1=1.21&r2=1.22&ty=u Index: phpdoc/en/appendices/migration5.xml diff -u phpdoc/en/appendices/migration5.xml:1.21 phpdoc/en/appendices/migration5.xml:1.22 --- phpdoc/en/appendices/migration5.xml:1.21 Fri May 28 06:56:36 2004 +++ phpdoc/en/appendices/migration5.xml Thu Jul 15 11:48:44 2004 @@ -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 @@ <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 @@ } } - $foo = new Setter(); $foo->n = 1; $foo->a = 100; @@ -1356,9 +1357,36 @@ ?> ]]> </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