8 tips for PHP scripts (7) PHP and Java

Source: Internet
Author: User
Another trick of PHP's efficacy is its ability to call methods of existing Java objects. This function allows you to integrate PHP into existing Java-based exploitation programs. If you are promoting PHP in your work, you can find the best features that can be blown up. another top trick of PHP is its ability to call methods of existing Java objects, this function allows you to integrate PHP into existing Java-based exploitation programs. If you are promoting PHP in your work, you can find the perfect spot. you know, Java is everywhere.

To use this function, you need to install the Java virtual machine (JVM) on the server ). If you plan to install (or have installed) JDK from Sun, Kaffe, IBM, or Blackdown, you are now on the right path.

When you configure PHP, you need to add the -- with-java parameter to the configuration command, and then modify your php. ini file. In php. ini, the following lines are usually corrected:

[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 corrections depend on your installation type. You should browse the README file in the ext/java directory under your PHP installation directory to learn more about Java function settings.

The following is a simple example: Create a PHP script for a new Java object. The script will then obtain some Java attributes and print them out. This is also a good example of COM.


$ System = new Java ('Java. lang. system ');
Echo'

Java version = '. $ system-> getProperty ('Java. version ').'
';
Echo 'Java vendor = '. $ system-> getProperty ('Java. upload ').'

';

?>

If you have mastered the Java knowledge, you must help developers to do a good job in this project. These types of integration functions must be the key to PHP development and human reception in the future. Therefore, the future of PHP will be even better if more people are doing such work.

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.