cvs: peardoc /en/package/webservices/xml-rpc api.xml examples.xml
| From: | Daniel Convissor | Date: | Fri, 07 Apr 2006 15:41:57 +0000 |
| Subject: | cvs: peardoc /en/package/webservices/xml-rpc api.xml examples.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-7731@lists.php.net to get a copy of this message | ||
danielc Fri Apr 7 15:41:57 2006 UTC
Modified files:
/peardoc/en/package/webservices/xml-rpc api.xml examples.xml
Log:
Clarify how to declare classes and objects for the function parameter. Bug 5094.
http://cvs.php.net/viewcvs.cgi/peardoc/en/package/webservices/xml-rpc/api.xml?r1=1.15&r2=1.16&diff_format=u
Index: peardoc/en/package/webservices/xml-rpc/api.xml
diff -u peardoc/en/package/webservices/xml-rpc/api.xml:1.15
peardoc/en/package/webservices/xml-rpc/api.xml:1.16
--- peardoc/en/package/webservices/xml-rpc/api.xml:1.15 Thu Jul 14 02:03:37 2005
+++ peardoc/en/package/webservices/xml-rpc/api.xml Fri Apr 7 15:41:57 2006
@@ -1051,6 +1051,11 @@
be a name of a function in the global scope which services the
XML-RPC method.
</para>
+ <para>
+ It is possible to use regular functions, class names with method
+ names and objects with method names. The Examples page of this
+ manual demonstrates the appropriate syntax for all of these approaches.
+ </para>
</listitem>
<listitem>
<para>
http://cvs.php.net/viewcvs.cgi/peardoc/en/package/webservices/xml-rpc/examples.xml?r1=1.7&r2=1.8&diff_format=u
Index: peardoc/en/package/webservices/xml-rpc/examples.xml
diff -u peardoc/en/package/webservices/xml-rpc/examples.xml:1.7
peardoc/en/package/webservices/xml-rpc/examples.xml:1.8
--- peardoc/en/package/webservices/xml-rpc/examples.xml:1.7 Sat May 7 23:51:00 2005
+++ peardoc/en/package/webservices/xml-rpc/examples.xml Fri Apr 7 15:41:57 2006
@@ -1,4 +1,4 @@
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<refentry id="package.webservices.xml-rpc.examples">
<refnamediv>
@@ -74,13 +74,48 @@
return new XML_RPC_Response($val);
}
+class some_class_name {
+ returnTimes2($params) {
+ $param = $params->getParam(0);
+
+ // This error checking syntax was added in Release 1.3.0
+ if (!XML_RPC_Value::isValue($param)) {
+ return $param;
+ }
+
+ $val = new XML_RPC_Value($param->scalarval() * 2, 'int');
+ return new XML_RPC_Response($val);
+ }
+}
+
+$some_object = new some_class_name;
+
+// Here are examples of the various ways to declare "functions":
$server = new XML_RPC_Server(
array(
- 'times2' =>
+ 'function_times2' =>
array(
'function' => 'returnTimes2'
- )
- )
+ ),
+ ),
+ array(
+ 'class_paamayim_nekudotayim_times2' =>
+ array(
+ 'function' => 'some_class_name::returnTimes2'
+ ),
+ ),
+ array(
+ 'class_times2' =>
+ array(
+ 'function' => array('some_class_name' =>
'returnTimes2'),
+ ),
+ ),
+ array(
+ 'object_times2' =>
+ array(
+ 'function' => array($some_object => 'returnTimes2'),
+ ),
+ ),
);
]]>
</programlisting>
@@ -94,7 +129,7 @@
$input = 8;
$params = array(new XML_RPC_Value($input, 'int'));
-$msg = new XML_RPC_Message('times2', $params);
+$msg = new XML_RPC_Message('function_times2', $params);
$cli = new XML_RPC_Client('/xmlrpc.php', 'localhost');
// $cli->setDebug(1);