Home  >  Article  >  Backend Development  >  8 Tips for PHP Scripting (7)_PHP Tutorial

8 Tips for PHP Scripting (7)_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:20:56813browse

PHP and Java

Another great feature of PHP is its ability to call methods of existing Java objects. This feature allows you to integrate PHP into existing Java-based applications. If you're promoting PHP in your workplace, you've got something to brag about because Java is everywhere.

In order to use this feature, you need to install a Java Virtual Machine (JVM) on the server. If you plan to install (or have already installed) a JDK from Sun, Kaffe, IBM or Blackdown, you are now on the right track.

When you configure PHP, you will need to add the --with-java parameter to the configuration directive and then modify your php.ini file. The following lines are usually modified in php.ini:

[Java]
java.library.path=/path/to/library
java.class.path=/classpath/
extension_dir=/path/to/extensions
extension=libphp_java .so

However, please note that these modifications will depend on your installation type. You should read the README file in the ext/java directory of your PHP installation to learn more about Java feature settings.

Here is a simple example: a PHP script that creates a new Java object. The script will then get certain Java properties and print them out. This is also a very good COM example.

$system = new Java("java.lang.System");
echo "

Java version = " . $system->getProperty("java.version") . "echo "Java vendor = " . $system->getProperty("java.vendor") . "

";

?>

If you already have knowledge of Java, then you must help the developers to complete this project. These types of integration features are bound to be key to the future development and acceptance of PHP, so the more people doing these jobs, the better the future of PHP will be.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532522.htmlTechArticlePHP and Java Another clever trick of PHP function is its ability to call methods of existing Java objects. This function Allows you to integrate PHP into existing Java-based applications. If you are...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn