How can I run PHP code within a Java application?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/614995/calling-php-from-java">Calling PHP from Java</a>  </p>
</blockquote>



<p>I was wondering how I could run PHP code within Java. Using the ScriptEngine, I am able to run JavaScript:</p>

<pre><code>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
}
</code></pre>

<p>To run this, I imported the library <code>javax.script.*</code>. 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 <code>php</code>. 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).</p>

<p>I hope I haven't missed anything out, and any help would be greatly appreciated!</p>
