Re: PHP Java problem

From: Date: Wed, 14 Jan 2004 00:10:19 +0000
Subject: Re: PHP Java problem
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-32383@lists.php.net to get a copy of this message
I don't know anything about Java in PHP myself, but here's a function that will convert an object to an associative array for you. 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; } Donovan Hutchinson wrote:
Hi, I've started putting together a site that uses PHP to access some custom Java classes. While I'm not clear on what exactly the java classes are doing, the programmer has given me an overview of the variables that I should pass to them. However, I keep getting this error: java.lang.IllegalArgumentException: argument type mismatch The java programmer has no knowledge of PHP and so is unable to help locate the source of the problem (tbh I'm don't have experience in large php projects myself). The code I'm writing is in the following format: $newobject = new Java('com.company.Class', $names, (String) $ssn, (int) $time); In the above example, $names is an object, $ssn a string and $time an integer. The object $names is created in a similar way above this example. Someone mentioned that I should be passing objects as arrays, but I'm not clear on how this is done. I've tested a very basic class to be sure it works, and had success, however when I try to pass objects into classes, and multiple variables, it doesnt work. I hope someone can shed some light on where I might be going wrong. Many thanks, Don
-- paperCrane <Justin Patrin> -- Question Everything, Reject Nothing

« previous php.db (#32383) next »