Home > Article > Backend Development > Two ways for PHP to call Java objects_PHP tutorial
1.php's Java module
The PHP release version contains a Java extension module that can be used to call Java objects, for example:
$system=new Java( "java.lang.System");
print "Java version=".$system->getProperty("java.version")."
";
?>
2.minij2ee application server SJOP protocol implementation
The main purpose of minij2ee application server to implement SJOP protocol is to enable EJB enterprise-level components to be accessed in php, so minij2ee provides an EJB-PHP compiler that can Compile EJB components into PHP classes so that EJB components can be conveniently called in PHP programs, for example:
require("Cart.php"); //Cart.php is The php class definition of Cart EJB generated after compiling Cart EJB
.
$home=new CartHome(); //Create the Home interface of EJB.
$objref=$home->create($cart_name); //Create Cart EJB.
$cart=new Cart($objref);
$cart->add("some goods"); //Add an item to the shopping cart.