2

I have a sample PHP class which I would like to Utilize in my Java Application.

We have decided to use Quercus as a Libary for doing the Integration.

Can some one let me know How can I call a PHP class from Java Code using Quercus.

For Example.

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.

Thanks,

Niraj Salot
  • 145
  • 1
  • 12

2 Answers2

1

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();

You then probably want engine.eval(reader);

woddle
  • 1,582
  • 1
  • 18
  • 34
1

You should look at QuercusEngine

import com.caucho.quercus.QuercusEngine;

QuercusEngine engine = new QuercusEngine();
engine.setOutputStream(System.out);
engine.executeFile("src/test.php");

Other examples

The only needed jars are resin.jar and servlet-api.jar.

h3xStream
  • 6,293
  • 2
  • 47
  • 57