问题描述
我有一个示例PHP类,我想在我的Java应用程序中使用它.
I have a sample PHP class which I would like to Utilize in my Java Application.
我们已决定使用Quercus作为集成库.
We have decided to use Quercus as a Libary for doing the Integration.
有人能让我知道如何使用Quercus从Java Code调用PHP类.
Can some one let me know How can I call a PHP class from Java Code using Quercus.
例如.
PHP类名是Calculator.php,它有一个方法sum(),它希望传递2个数字,然后将这些数字求和.
PHP class name is calculator.php and it has one method say sum() which expects 2 numbers to be passed and It will do the summation of those number.
请让我知道可以被编码以实现相同的示例代码.
Please let me know the sample code which can be coded to achive the same.
谢谢
推荐答案
这些天,您似乎无法有效地实例化QuercusEngine.相反:
It seems that you can't usefully instantiate a QuercusEngine these days. Instead:
import javax.script.ScriptEngine;
import com.caucho.quercus.script.QuercusScriptEngineFactory;
QuercusScriptEngineFactory factory = new QuercusScriptEngineFactory();
ScriptEngine engine = factory.getScriptEngine();
然后您可能想要engine.eval(reader);
这篇关于使用Quercus从Java进行PHP调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!