From: <php...@li...> - 2007-05-31 07:22:38
|
Hi, > Is it expected behavior that > Integers, Floats, > Doubles, and Longs need to be converted with > java_values() before being > used in a PHP context? not that I know of. The PHP/Java Bridge protocol shouldn't touch integral types(integer, boolean, ...). BTW: The bridge doesn't convert anything. A java.lang.String and a java.lang.Integer is not converted (unless you use the deprecated php 4 java.so). What you probably mean is: How are objects displayed? The standard procedure is ObjectToString(Object ob), see JavaBridge.java, which displays all objects as [o(Type):StringRepresentation]. The only exception is the String type, there exists a method ObjectToString(String ob) which displays the object as "StringRepresentation". We could remove the ObjectToString(String o) and modify ObjectToString(Object o) so that o->toString() is called for any object. But you need to convince me that such a behaviour is useful. :) > $integer = new Java('java.lang.Integer', 123); > // displays [[o:Integer]:"123"] Well Integer is an object, not primitive type. Isn't it possible to pull the integer value from the above Integer object and display that? For example: echo $Integer->getIntValue(); should display 123. > // displays notice "could not be converted to int" > if ($integer == 123) echo 'equal'; else That's why I'd like to keep the current behaviour. Your $integer is a java object, not a primitive type. Displaying it as "123" will make the debugging process more difficult. However, you are probably upgrading from PHP4, where autoconversion was the default behavour. There is a protocol header option. Regards, Jost Boekemeier ___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de |