从 PHP5 调用 Java 方法 [英] Call Java method from PHP5

查看:33
本文介绍了从 PHP5 调用 Java 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

曾经有一个 PHP 扩展可以加载Java 库和其中的调用方法.那是针对 PHP 4 的.

There used to be a PHP extension that could load Java libraries and call methods in them. That was for PHP 4.

有没有办法在 PHP 5 中做同样的事情?

Is there a way to do the same in PHP 5?

推荐答案

看起来没有内置方式,甚至 php4 中的支持也是实验性的.在每个 php 请求上启动 Java 虚拟机真的没有意义.如果您必须在 Java 中执行某些操作,则始终可以使用 shell 转义功能(反引号运算符),但是如果您想使某些内容具有可扩展性,则它需要是它自己的 Java 服务并接受 SOAP/REST 或您想与之交谈的任何方式来自 php.

Doesn't look like there's a built-in way, even the support in php4 was experimental. Doesn't really make sense to start up a Java Virtual Machine on each request for php. You could always use the shell-escaping capabilities (backtick operator) if you have to do something in Java but if you want to make something scalable it needs to be its own Java service and accept SOAP/REST or however you want to talk to it from php.

这篇关于从 PHP5 调用 Java 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆