function _xmlrpc_example_server_subtract in Examples for Developers 7
Same name and namespace in other branches
- 6 xmlrpc_example/xmlrpc_example.module \_xmlrpc_example_server_subtract()
This is the callback for the xmlrpc_example.subtract xmlrpc method.
Return the difference of the two arguments, or an error if the result is out of the configured limits.
Parameters
int|float $num1: First number
int|float $num2: Second number
Return value
int|float 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 263 - Module file for xmlrpc_example module.
Code
function _xmlrpc_example_server_subtract($num1, $num2) {
$diference = $num1 - $num2;
$max = variable_get('xmlrpc_example_server_max', 10);
$min = variable_get('xmlrpc_example_server_min', 0);
// If result is not within maximum and minimum limits,
// return corresponding error.
if ($diference > $max) {
return xmlrpc_error(10001, t('Result is above the upper limit (@max) defined by the server.', array(
'@max' => $max,
)));
}
if ($diference < $min) {
return xmlrpc_error(10002, t('Result is below the lower limit (@min) defined by the server.', array(
'@min' => $min,
)));
}
// Otherwise return the result.
return $diference;
}