Possible Duplicate:
Calling PHP from Java
I was wondering how I could run PHP code within Java. Using the ScriptEngine, I am able to run JavaScript:
String code="print(5+5);"; //sample bit of code
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByExtension("js");
try {
engine.eval(code);
} catch (ScriptException ex) {
//catch statement
}
To run this, I imported the library javax.script.*
. I believe to run PHP I would have to import a similar library, and change the third line of the code above to the extension php
. Unfortunately, I don't know which library this is. I have Googled to try and find the answer, and came across the PHP/Java Bridge library but I don't think this is exactly what I'm looking for, as it is focussed on running Java through PHP (as far as I know).
I hope I haven't missed anything out, and any help would be greatly appreciated!