本文整理汇总了PHP中xmlrpcval::addScalar方法的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpcval::addScalar方法的具体用法?PHP xmlrpcval::addScalar怎么用?PHP xmlrpcval::addScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpcval
的用法示例。
在下文中一共展示了xmlrpcval::addScalar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmlrpc_encode
function xmlrpc_encode($php_val)
{
global $xmlrpcInt;
global $xmlrpcDouble;
global $xmlrpcString;
global $xmlrpcArray;
global $xmlrpcStruct;
global $xmlrpcBoolean;
$type = gettype($php_val);
$xmlrpc_val = new xmlrpcval();
switch ($type) {
case "array":
case "object":
$arr = array();
while (list($k, $v) = each($php_val)) {
$arr[$k] = xmlrpc_encode($v);
}
$xmlrpc_val->addStruct($arr);
break;
case "integer":
$xmlrpc_val->addScalar($php_val, $xmlrpcInt);
break;
case "double":
$xmlrpc_val->addScalar($php_val, $xmlrpcDouble);
break;
case "string":
$xmlrpc_val->addScalar($php_val, $xmlrpcString);
break;
// <G_Giunta_2001-02-29>
// Add support for encoding/decoding of booleans, since they are supported in PHP
// <G_Giunta_2001-02-29>
// Add support for encoding/decoding of booleans, since they are supported in PHP
case "boolean":
$xmlrpc_val->addScalar($php_val, $xmlrpcBoolean);
break;
// </G_Giunta_2001-02-29>
// </G_Giunta_2001-02-29>
case "unknown type":
default:
// giancarlo pinerolo <ping@alt.it>
// it has to return
// an empty object in case (which is already
// at this point), not a boolean.
break;
}
return $xmlrpc_val;
}
示例2: bitflipper
function bitflipper($m)
{
global $xmlrpcArray;
$v = $m->getParam(0);
$sz = $v->arraysize();
$rv = new xmlrpcval(array(), $xmlrpcArray);
for ($j = 0; $j < $sz; $j++) {
$b = $v->arraymem($j);
if ($b->scalarval()) {
$rv->addScalar(false, "boolean");
} else {
$rv->addScalar(true, "boolean");
}
}
return new xmlrpcresp($rv);
}
示例3: processResult
function processResult($result)
{
$ret = new xmlrpcval();
if (is_object($result)) {
$result = get_object_vars($result);
}
if (is_associative_array($result)) {
$ar = array();
$keys = array_keys($result);
foreach ($keys as $k) {
$tmp = new xmlrpcval(array($k => new xmlrpcval($result[$k])), 'struct');
$ar[] = $tmp;
}
$ret->addArray($ar);
} else {
if (is_array($result)) {
foreach ($result as $key => $value) {
if (!is_string($value)) {
$tmp = processResult($value);
} else {
$tmp = new xmlrpcval();
$tmp->addScalar($value);
}
$result[$key] = $tmp;
}
$ret->addArray($result);
} else {
if (is_bool($result)) {
$ret->addScalar($result, "boolean");
} else {
$ret->addScalar($result);
}
}
}
return $ret;
}