function _xmlrpc_example_server_subtract in Examples for Developers 6
Same name and namespace in other branches
- 7 xmlrpc_example/xmlrpc_example.module \_xmlrpc_example_server_subtract()
Return the difference of the two arguments.
This is the callback for the xmlrpc_example.subtract xmlrpc method.
Parameters
numeric $num1:
numeric $num2:
Return value
The difference of the two arguments, or error if it is not in server defined bounds.
See also
Related topics
1 string reference to '_xmlrpc_example_server_subtract'
- xmlrpc_example_xmlrpc in xmlrpc_example/
xmlrpc_example.module - Implements hook_xmlrpc().
File
- xmlrpc_example/
xmlrpc_example.module, line 193 - This is an example of how to implement an XML-RPC server by registering callbacks to specific methods and how to make xmlrpc calls using the builtin xmlrpc() factory provided by Drupal.
Code
function _xmlrpc_example_server_subtract($num1, $num2) {
$diference = $num1 - $num2;
// If result is not within maximum and minimum limits, return corresponding error
if ($diference > variable_get('xmlrpc_example_server_max', 10)) {
return xmlrpc_error(10001, t("Result is over the higher limit defined by the server."));
}
if ($diference < variable_get('xmlrpc_example_server_min', 0)) {
return xmlrpc_error(10002, t("Result is under the lower limit defined by the server."));
}
// Otherwise return the result.
return $diference;
}