Quick Master PHP Call Java language method _php tutorial

Source: Internet
Author: User

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:

    1. < ? PHP
    2. $ system = New Java ("Java.lang.System");
    3. print "Java version = ". $system- >
      getProperty ("java. Version"). "
    4. <br> / n ";
    5. ?>

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:

 
  
  
  1. < ? PHP
  2. $ Conn = minij2ee_fetch_connection ();
  3. version = ". Minij2ee_
    Callstatic_javaobj ($conn, "Java.lang".
    System "," GetProperty "," Java.lang. "
    String "," Java.version ")."
  4. < BR > / n " ;
  5. ?>

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:

 
 
    1. < ? PHP
    2. Require ("cart.php");
    3. File://Cart.php is a compiled Cart
      The PHP class definition for the cart EJB generated after the EJB.
    4. $ Home = New Carthome ();
    5. FILE://Create the home interface of the EJB.
    6. $ ObjRef = $home- > Create ($cart _name);
    7. file://Create a cart EJB.
    8. $ Cart = New Cart ($OBJREF); $cart- > Add ("some goods");
    9. file://add an item to the shopping cart.
    10. ?>

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 ...

  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.