From 1d2a83caf4659aeba6614444b37e47ea67df58a4 Mon Sep 17 00:00:00 2001 From: gggeek Date: Sun, 8 Jan 2023 15:24:16 +0000 Subject: [PATCH] more demo files improvements --- demo/client/which.php | 2 +- demo/vardemo.php | 42 ++++++++++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/demo/client/which.php b/demo/client/which.php index b3b93e32..07fb3dc6 100644 --- a/demo/client/which.php +++ b/demo/client/which.php @@ -47,7 +47,7 @@ if (!$resp->faultCode()) { $response = $encoder->decodeXml($xml); // from Response to Value $value = $response->value(); - // from value to php + // from Value to php $value = $encoder->decode($value); output("Toolkit info:
\n"); diff --git a/demo/vardemo.php b/demo/vardemo.php index be748f7f..66ed3ea7 100644 --- a/demo/vardemo.php +++ b/demo/vardemo.php @@ -64,18 +64,31 @@ output("Struct:
" . htmlentities($v->serialize()) . "
"); $w = new PhpXmlRpc\Value(array($v), 'array'); output("Array containing a struct:
" . htmlentities($w->serialize()) . "
"); -/*$w = new PhpXmlRpc\Value("Mary had a little lamb, -Whose fleece was white as snow, -And everywhere that Mary went -the lamb was sure to go. - -Mary had a little lamb -She tied it to a pylon -Ten thousand volts went down its back -And turned it into nylon", "base64" -); -output("
" . htmlentities($w->serialize()) . "
"); -output("
Value of base64 string is: '" . $w->scalarval() . "'
");*/ +class MyClass +{ + public $public = 'a public property'; + protected $protected = 'a protected one'; + private $private = 'a private one'; +} +$myObject = new MyClass(); +// the public property is the only one which will be serialized. As such, it has to be of type Value +$myObject->public = new \PhpXmlRpc\Value('a public property, wrapped'); +$w = new PhpXmlRpc\Value($myObject, 'struct'); +output("Struct encoding a php object:
" . htmlentities($w->serialize()) . "
"); + +output("

Testing value serialization - xmlrpc extensions

\n"); +$v = new PhpXmlRpc\Value(1234, 'i8'); +output("I8:
" . htmlentities($v->serialize()) . "
"); +$v = new PhpXmlRpc\Value(null, 'null'); +output("Null:
" . htmlentities($v->serialize()) . "
"); +\PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_apache_encoding = true; +output("Null, alternative:
" . htmlentities($v->serialize()) . "
"); + +output("

Testing value serialization - character encoding

\n"); +// The greek word 'kosme' +$v = new PhpXmlRpc\Value('κόσμε'); +output("Greek (default encoding):
" . htmlentities($v->serialize()) . "
"); +output("Greek (utf8 encoding):
" . htmlentities($v->serialize('UTF-8')) . "
"); output("

Testing request serialization

\n"); $req = new PhpXmlRpc\Request('examples.getStateName'); @@ -98,4 +111,9 @@ output("Which comes out at " . PhpXmlRpc\Helper\Date::iso8601Encode($tb) . "\n") output("Which was the time in UTC at " . PhpXmlRpc\Helper\Date::iso8601Encode($tb, 1) . "\n"); output("\n"); +output("

Testing reduced-precision formatting for doubles

\n");
+$v = new PhpXmlRpc\Value(1234.56789, 'double');
+\PhpXmlRpc\PhpXmlRpc::$xmlpc_double_precision = 2;
+output("Double, limited precision: 
" . htmlentities($v->serialize()) . "
"); + output(''); -- 2.47.0