function add2numbers($num1, $num2) {
if (trim($num1) != intval($num1)) {
return new soap_fault('Client', '', 'The first number is invalid');
}
if (trim($num2) != intval($num2)) {
return new soap_fault('Client', '', 'The second number is invalid');
}
return ($num1 + $num2);
}
?>
include('nusoap.php');
$client = new soapclient('');
$str = "This string will be reversed";
$params1 = array('str'=>$str);
$reversed = $client->call('reverse',$params1);
echo "If you reverse '$str', you get '$reversed' \n";
$n1 = 5;
$n2 = 14;
$params2 = array('num1'=>$n1, 'num2'=>$n2);
$added = $client->call('add2numbers', $params2);
echo "If you add $n1 and $n2 you get $added \n";
?>