Iam New to Java, can we call php script using java,so anyone can help to solve my doubt
Printable View
Iam New to Java, can we call php script using java,so anyone can help to solve my doubt
The most direct way to call a PHP script, if the PHP script works on its own, such as a command line script, would be to do it through a child process, such as the Runtime.exec() facility from your [command line] Java application.
If the PHP script exists within a web server, it is likley best (and probably not even possible to do so other than) to invoke it using the HTTP interface, so using a java HTTP client such as the commons-httpclient.
I also know of the PHP/Java Bridge project, but that is more like a XML based remote procedure call, and it is mainly for calling java from inside PHP (the other direction than you want here), but it might have some resources to help you get to PHP from in Java, i haven't got into it too much detail yet.
There is also the Quecius project, which is a Java implementation of a PHP interpreter, in theory it would let you run PHP code inside the Quercious (e.g. Java) based container. Surely there would be some kind of hooks to have other Java pieces invoke a PHP script within the Quercius container, but I suspect this is a bit heavy weight and would take a lot of playing in general to make sure the PHP application will function inside Quercius.
Thank You Very much for u reply Mr.Travishein