10 Tips for PHP scripts (from ZDNet)--php and Java

Source: Internet
Author: User
Tags ini php and php script version
Tricks | scripting PHP and Java

Another idea of PHP is its ability to invoke methods of existing Java objects, which allows you to integrate PHP into existing java-based applications. If you are in your workplace to promote PHP, then you find a big blow to the beautiful point, you know, Java this stuff everywhere.

 

To use this functionality, you need to install the Java Virtual Machine (JVM) on the server. If you plan to install (or have already installed) JDK from Sun, Kaffe, IBM or Blackdown, you are now in the right path.

When you configure PHP, you will need to add--with-java parameters to the configuration instructions and then modify your php.ini file. The following lines are typically 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 changes are dependent on your installation type. You should read the Readme file in the Ext/java directory under your PHP installation directory to learn more about the Java feature settings.

 

Here's a simple example: a PHP script that creates a new Java object. The script will then get some Java attributes and print them out. This is also a good example of COM.

?

$system = new Java ("Java.lang.System");
echo "<p>java Version =". $system->getproperty ("Java.version"). "<br>";
echo "Java vendor =". $system->getproperty ("Java.vendor"). "</p>";

?>

If you already have knowledge of Java, you must help the developer do the project well. These types of integration features are bound to be the key to future PHP development and acceptance, so the future of PHP will be much better with more people doing the 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.