xmlrpc_set_type

Description

xmlrpc_set_type
( string&$value
, string$type
) : bool

Sets xmlrpc type, base64 or datetime, for a PHP string value.

Warning

This function is
EXPERIMENTAL. The behaviour of this function, its name, and
surrounding documentation may change without notice in a future release of PHP.
This function should be used at your own risk.

Parameters

value

Value to set the type

type

'base64' or 'datetime'

Return Values

Returns TRUE on success or FALSE on failure.
If successful, value is converted to an object.

The problem is that PHP has a string type which is also used to hold binary data and dates. But XML-RPC defines three separate types for strings, binary data, and dates. How do you tell how you want strings encoded? That's where this function comes in.

Suppose the XML-RPC method "log.data" took a string, a date, and a binary object. To tell XML-RPC that the date (which is a PHP string) is a really a date and that the binary data (which is also a PHP string) is really binary data, try:

Note the reference passing in the calls to xmlrpc_set_type; that enables the function to change the values from strings into what xmlrpc_encode/_request expects (which are objects that include a bonus field that tells the desired XML-RPC type).