Another advantage of PHP functionality is its ability to call existing Java object methods. This feature allows you to integrate PHP into existing Java-based applications. This feature is especially trendy if you're promoting PHP in the workplace. "Java is everywhere."
To achieve this feature, you need to install a Java Virtual Machine (JVM) on the server. If you will install (or have installed) a JDK from Sun, Kaffe, IBM or Blackdown, you can start working quickly.
When configuring PHP, you need to add the --with-java parameter to the configuration directive, and then modify some elements in the 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
Please note that the above modifications 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 configuration.
Here is a simple example: creating a new Java object through a PHP script. The script will then access certain Java properties and output them. This is just as exciting as the COM example, but it also gives you an idea of many more possible approaches.
$system = new Java("java.lang.System");
echo "
Java version = " . $system- >getProperty("java.version") . "
";
echo "Java vendor = " . $system->getProperty("java.vendor") . "
?>
If you already have Java knowledge, you should do your best to help developers on this project. Such integration capabilities will inevitably become the key to the future development and acceptance of PHP. Therefore, the more people who do these jobs, the better the future development of PHP will be.