XML_PRC can't work correctly with statement "foreach (array as $value)"

From: Date: Mon, 28 Feb 2005 05:54:50 +0000
Subject: XML_PRC can't work correctly with statement "foreach (array as $value)"
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17719@lists.php.net to get a copy of this message
My Develop environment: win2000 php 4.3.11 DB 1.6.8 XML_RPC 1.2.0 XML_PRC can't work correctly with statement "foreach (array as $value)". When I use "foreach (array_expression as $value) statement", It cause an error, "$value" can't get correct value, but I use "foreach (array_expression as $key => $value) statement", It is correct. I post my script file here: Client.php ------------------------------------------------------------ <?php require_once('XML/RPC.php'); $function = "foreachArray"; $message = new XML_RPC_Message($function); $client = new XML_RPC_Client("/bugs/Server.php", "localhost", 80); $result = $client->send($message); echo "<p><b>Function Call:</b> $function()</p>"; echo "<p><b>Sent XML Message:</b>" . "<pre>" . htmlentities($message->serialize()) . "</pre></p>"; $value = $result->value(); if (!isset($value)) { die("send failed"); } $isSuccess = $value->scalarval(); echo "<p><b>Return Value:</b> $isSuccess </p>"; echo "<p><b>Received XML Message:</b>" . "<pre>" . htmlentities($result->serialize()) . "</pre></p>"; ?> ------------------------------------------------------------ Server.php ------------------------------------------------------------ <?php require_once('XML/RPC/Server.php'); require_once('Handle.php'); $foreachArraySig = array(array("string")); $foreachArrayArr = array("function" => "foreachArray", "signature" => $foreachArraySig); $dispMap = array("foreachArray" => $foreachArrayArr); new XML_RPC_Server($dispMap); ?> ------------------------------------------------------------ Handle.php ------------------------------------------------------------ <?php function foreachArray($message) { $str = null; $ar = array("How", "do", "you", "do"); //foreach ($ar as $key => $value) { foreach ($ar as $value) { $str .= $value; } $result = new XML_RPC_Value($str, "string"); return new XML_RPC_Response($result); } ?> ------------------------------------------------------------ expected response(in browser): ------------------------------------------------------------ Function Call: foreachArray() Sent XML Message: <?xml version="1.0"?> <methodCall> <methodName>foreachArray</methodName> <params> </params> </methodCall> Return Value: Howdoyoudo Received XML Message: <methodResponse> <params> <param> <value><string>Howdoyoudo</string></value> </param> </params> </methodResponse> ------------------------------------------------------------ but I get unexpected response(in browser): ------------------------------------------------------------ Function Call: foreachArray() Sent XML Message: <?xml version="1.0"?> <methodCall> <methodName>foreachArray</methodName> <params> </params> </methodCall> Return Value: ArrayArrayArrayArray Received XML Message: <methodResponse> <params> <param> <value><string>ArrayArrayArrayArray</string></value> </param> </params> </methodResponse> ------------------------------------------------------------ bluemonkey157@hotmail.com 2005-02-28

« previous php.pear.general (#17719) next »