10 Tips for PHP Scripting (7)_PHP Tutorial

WBOY
Release: 2016-07-21 16:04:47
Original
835 people have browsed it

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 the above 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 developer 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/315841.htmlTechArticlePHP and Java Another trick of PHP’s functionality is its ability to call methods of existing Java objects. This functionality Allows you to integrate PHP into existing Java-based applications. If you are on your...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template