Re: Re: PHP Java problem

From: Date: Wed, 14 Jan 2004 20:58:26 +0000
Subject: Re: Re: PHP Java problem
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-32394@lists.php.net to get a copy of this message
Thanks Justin, thats a handy function. I've been testing my code and found that it works up until I start passing objects into methods. This is the code I'm using to set up some objects (they are being passes variables that have been settype()'d): $sessioniser = new Java('com.SessionManager', "adam", ""); $homeaddress = new Java('com.Address', $hline1, $hline2, $hline3, $hline4, $hline5, $hline6); $deliveryaddress = new Java('com.Address', $dline1, $dline2, $dline3, $dline4, $dline5, $dline6); $name = new Java('com.Name', $firstname, $middlename, $lastname); $coname = new Java('com.Name', $cofirstname, $comiddlename, $colastname); When I print_r each of these, it produces these results: Sessioniser: java Object ( [0] => 8 ) HomeAddress: java Object ( [0] => 9 ) DeliveryAddress: java Object ( [0] => 10 ) Name: java Object ( [0] => 11 ) CoName: java Object ( [0] => 12 ) These objects do not correspond to the data I'm passing in to them. I've asked the programmer why this is the case and he has shown his classes working using a command line. I must be doing something wrong in php but can't see what. Any suggestions most appreciated. Thanks, Don > function objToAssoc($obj) { > if(is_object($obj)) { > $arr = get_object_vars($obj); > } else { > $arr = $obj; > } > if(is_array($arr)) { > foreach($arr as $key => $val) { > $arr[$key] = objToAssoc($val); > } > } > return $arr; > } >

« previous php.db (#32394) next »