First, you must know which special functions (PHP classes) are created by the PHP/Java bridge for integrating Java classes in PHP scripts, including:
◆java: It allows you to access Java types with a given name, such as:
◆java("")->getProperties();
◆java_autoload: It allows you to load a set of Java libraries in the current PHP script, such as:
◆java_autoload("my_1.jar;my_2.jar");
◆java_cast: It allows you to convert a Java object into a PHP value, such as:
$mystr=new java("","9");$phpnr=java_cast($mystr,"integer");echo $ phpnr;
◆java_is_null: You can use it to check whether the value is empty, such as:
◆java_is_null(java("")->;getProperty("my_prop"))
◆java_session: You can use it to return a session handle, such as:
$session = java_session();
◆java_values: You can use it to evaluate objects and extract their contents (only if this operation is possible), such as:
$result = java_values($calcinstance->addAB($term_1,$term_2));
In order to use these functions, your PHP application must contain the corresponding PHP classes. The most important class is that there is a complete list of classes in the directory appName/java. Through, you can obtain instances of Java classes, such as:
$calcinstance=new Java("");
Author reminder: There are more functions and their detailed information under the installation directory /documentation/API of PHP/Java bridge. Using Java classes in PHP scripts
Using PHP scripts in Java classes
In order to call PHP methods in Java applications, you must be very familiar with the Java API, the most important class of this API is:
: This class extends the class and provides an instantiation mechanism for the ScriptEngine class.
: This is a Java interface, including the full functionality expected in each Java ScriptEngine, which is implemented through classes such as AbstractScriptEngine, InteractivePhpScriptEngine, InvocablePhpScriptEngine, InvocablePhpServletScriptEngine, PhpScriptEngine, and PhpServletScriptEngine.
?
: This interface provides a function that allows java applications to call intermediate-layer code under the script compiler.
Author reminder: There are more classes and their detailed information in the /documentation/server/documentation/API directory.
Previous page1234Next pageRead the full text