PHP calls the Java language one. PHP java module
The PHP release contains a Java extension module that can be used to invoke Java objects, such as:
- < ? PHP
- $ system = New Java ("Java.lang.System");
- print "Java version = ". $system- >
getProperty ("java. Version"). "
- <br> / n ";
- ?>
The advantage of using this method is that it is convenient to use new Java () to create a Java object, and you can invoke the Java object just like the PHP class. But this approach also has the following obvious drawbacks:
1. Because PHP's Java module chooses the most appropriate Java method based on the PHP data type, it is not possible to invoke Java overloaded functions.
The 2.php Java module will load the JVM (Java Virtual machine) in the current Web server's process, so the overhead of the Web server process is greatly affected by the execution efficiency.
3. In some operating systems and Web server environments, PHP's Java modules will make the Web server process zombie.
For these reasons, PHP's Java module has not been applied to the actual software system. ---www.002pc.com
PHP calls the Java language two. MINIJ2EE Application Server SJOP protocol implementation
Before introducing MINIJ2EE Application Server SJOP protocol implementation, let's briefly introduce the MINIJ2EE application server. The MINIJ2EE application server is the first Java EE Application Server product that supports PHP, enabling PHP to be used to develop enterprise application systems. SJOP Full name is the sample Java ORB Protocol (simple Java Object Request Proxy protocol), is a simple and efficient object request proxy protocol. Like what:
- < ? PHP
- $ Conn = minij2ee_fetch_connection ();
- version = ". Minij2ee_
Callstatic_javaobj ($conn, "Java.lang".
System "," GetProperty "," Java.lang. "
String "," Java.version ")."
- < BR > / n " ;
- ?>
The main purpose of the MINIJ2EE application server implementation of the SJOP protocol is to enable access to EJB Enterprise components in PHP, so MINIJ2EE provides a ejb-php compiler that can compile EJB components into PHP classes, making it easy to invoke EJB components in PHP programs. For example:
- < ? PHP
- Require ("cart.php");
- File://Cart.php is a compiled Cart
The PHP class definition for the cart EJB generated after the EJB.
- $ Home = New Carthome ();
- FILE://Create the home interface of the EJB.
- $ ObjRef = $home- > Create ($cart _name);
- file://Create a cart EJB.
- $ Cart = New Cart ($OBJREF); $cart- > Add ("some goods");
- file://add an item to the shopping cart.
- ?>
Using PHP MINIJ2EE Application Server to call the Java language method, you can develop a PHP and Java EE Technology-based, object-oriented, stable and efficient enterprise-class application system.
http://www.bkjia.com/PHPjc/446029.html www.bkjia.com true http://www.bkjia.com/PHPjc/446029.html techarticle PHP calls Java language one. PHP's Java module PHP release contains a Java extension that can be used to invoke Java objects such as: PHP $ system = new Java (java.lang.System); Printjava ...