The P>java language is powerful, so it is useful to invoke Java functionality in PHP in many cases. There are two ways to invoke the Java language in PHP, one is to use the Java extensions in PHP, and the other is to use the SJOP protocol implementation provided by the MINIJ2EE application server. Now let's compare the characteristics of the two methods.
1.php of Java Modules
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>";
?>
The advantage of using this method is that it is convenient to use the new Java () to create a Java object, you can invoke Java objects like the PHP class. But this approach also has the following obvious disadvantages:
1. Because PHP's Java module chooses the most appropriate Java method based on the PHP data type, the Java overload function cannot be invoked.
2.php Java modules are loaded into the JVM (Java Virtual Machine) in the process of the current Web server, so the system overhead is significant and affects the execution efficiency of the Web server process.
3. In some operating systems and Web server environments, PHP's Java modules will make the Web server process zombie. See http://www.php.net/bugs.php?id=6122.
For these reasons, PHP's Java modules have been unable to apply to the actual software system.
2.MINIJ2EE Application Server SJOP protocol implementation
Before introducing the implementation of MINIJ2EE Application Server SJOP protocol, briefly introduce the MINIJ2EE application server. The MINIJ2EE application server is the first Java EE Application Server product that enables PHP to be used to develop enterprise application systems. The SJOP full name is the sample Java ORB Protocol (simple Java Object Request Broker protocol), which is a simple and efficient object request broker protocol. Like what:
<?php
$conn =minij2ee_fetch_connection ();
Print "Java version=". Minij2ee_callstatic_javaobj ($conn, "Java.lang.System", "GetProperty", "java.lang.String", " Java.version ")." <br> ";
?>
The main purpose of the MINIJ2EE Application Server implementation SJOP protocol is to enable PHP to access EJB Enterprise-class components, so MINIJ2EE provides a ejb-php compiler that compiles 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 the PHP class definition of the cart EJB generated after you compile the cart EJB.
$home =new carthome (); FILE://creates the home interface for the EJB.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.