![]() |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Resin 3.1 Documentation Tutorials Changes Overview Installation Configuration Quercus SOA/IoC JSP Servlets and Filters Admin (JMX) EJB Amber Security Performance Hessian XML and XSLT Third-party Troubleshooting/FAQ Overview Module Status Resin Module Java Interface Troubleshooting FAQ |
Quercus types, Java-Quercus type mappings, working with Java Classes in PHP IntroductionWorking with Quercus Quercus TypesFor every PHP type, there is a Quercus type that is used
internally to represent the corresponding PHP value. All Quercus types extend
Quercus natively supports Unicode and is compatible with the new PHP 6 syntax. Java Method ArgumentsIn Quercus, Java methods can be called from within PHP. Java arguments for Java methods need to be marshaled to the correct type from the PHP parameters that were passed in.
When the Java argument type is declared to be Object, the value will be marshaled to a Java object. For example, a PHP int (LongValue) will be marshaled to an Integer. The only exceptions are PHP arrays and objects: they are passed in as-is without marshaling. When the Java argument type is declared to be a Quercus Value, the PHP value is passed in directly without marshaling. If the Java argument is an object, passing in a PHP NULL will set the Java argument to null. Java Method ReturnsWhen a Java method is called from PHP code, the return value of that Java method needs to be marshaled into a valid Quercus value.
Java objects like Calendar and Map are placed inside JavaValues and then
returned to the PHP environment. A JavaValue is just a wrapper that exposes
the object's Java methods to PHP. For example, if Some Java objects may have an effective PHP value. Take for instance, Date. A Date object is, for practical purposes, a PHP int with it's value pegged to Date.getTime(). Collection, List, and Map behave just like PHP arrays. Suppose
Working with Java Classes in PHPGetting Static ClassesJava classes can be accessed by PHP by using the
<?php
$a = java("java.lang.System");
echo $a->nanoTime();
?>
Instantiating ObjectsTo get new instances of Java ojects, use
<?php
$a = new java("java.util.Date", 123);
echo $a->nanoTime();
?>
java() and new java() have the same behavior
and may be used interchangeably.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||