PHP Returned Result into slice struct

dthompsondthompson Member Don ThompsonOrganization: Digital Federal Credit UnionProject: credit card fraud monitoring
How do you place the returned result from server call into a struct in PHP?
I see page with example of writing a slice struct to the server, but not how to
retrieve the data:
This is likely due to my unfamilarity with PHP. I've been working
on the c++ server and clients, and am now trying to produce a simple PHP test page.

slice fragment:
module CU
{ // System Login Info
struct System {
bool loggedIn;
int postdate;
string sysname;
string syslocation;
int sysflags;
string username;
int userid;
int userbranch;
string userlocation;
int userflags;
interface CULoan
System login(int userid, string pw) throws InvalidUser;
PHP Page fragment:
$sysrec = $gcu->login(148, "junkjunk");
foreach ($sysrec as $s => $val)
echo "<B>\t" . $s . " = " . $val . "<BR></B>\n";

PHP Page results returned:

loggedIn = 1
postdate = 2006-04-02
sysname = GNU FCU
syslocation = Worcester
sysflags = 1862869560
username = Carol Jones
userid = 148
userbranch = 75
userlocation = Marlboro
userflags = 1768187255

I would like these results into a struct of type System.


  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Don,
    dthompson wrote:
    I would like these results into a struct of type System.
    The return value of login is an instance of a PHP class that represents your struct type System. It just so happens that PHP5 allows you to iterate over objects using the foreach keyword, just like for arrays. To confirm this, add the following code:
    echo "The type of sysrec is " . get_class($sysrec) . "\n";
    echo "The value of sysname is " . $sysrec->sysname . "\n";
    Hope that helps,
    - Mark
Sign In or Register to comment.