* Refine examples: remove return on bad get, show case of $name in call methods.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@256673 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Daniel Convissor 2008-04-02 20:27:13 +00:00
parent be9bbbab5e
commit d06dfc1004

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.27 $ -->
<!-- $Revision: 1.28 $ -->
<sect1 xml:id="language.oop5.overloading" xmlns="http://docbook.org/ns/docbook">
<title>Overloading</title>
@ -168,8 +168,6 @@ class MemberTest {
' in ' . $trace[0]['file'] .
' on line ' . $trace[0]['line'],
E_USER_NOTICE);
$tmp = null;
return $tmp;
}
/** As of PHP 5.1.0 */
@ -271,29 +269,31 @@ Notice: Undefined property: hidden in <file> on line 64 in <file> on line 28
<?php
class MethodTest {
public function __call($name, $arguments) {
// Note: value of $name is case sensitive.
echo "Calling object method '$name' "
. implode(', ', $arguments). "\n";
}
/** As of PHP 5.3.0 */
public static function __callStatic($name, $arguments) {
// Note: value of $name is converted to lower case.
echo "Calling static method '$name' "
. implode(', ', $arguments). "\n";
}
}
$obj = new MethodTest;
$obj->test('in object context');
$obj->runTest('in object context');
MethodTest::test('in static context'); // As of PHP 5.3.0
MethodTest::runTest('in static context'); // As of PHP 5.3.0
?>
]]>
</programlisting>
&example.outputs;
<screen role="php">
<![CDATA[
Calling object method 'test' in object context
Calling static method 'test' in static context
Calling object method 'runTest' in object context
Calling static method 'runtest' in static context
]]>
</screen>
</example>