You can't wrap or extend PHP code from Java the way you would a Java library, but you might be able to call PHP code on your server and work with the results from your own Java application. See How can I execute a PHP script from Java?
Barring than that, I agree with the comment above. It might be easier to either learn PHP or rewrite the parts of the code that you need in Java.
After seeing in your comments what PHP tool you're talking about, rewriting in Java doesn't seem like much of an option. If you're starting a site from scratch (meaning you don't already have a Java application that you want to add this to) then PHP is not that hard to learn. Other than that, you could look for Java projects that do the same thing as the PHP tool you're looking at now.
Well, it would be useful if you'd tell us what exactly your PHP tool/framework does, maybe even give us a link to it's site, then I'm sure you'll get tons of recommandations for corresponding Java tool/framework that does the same thing. I don't think you need to remake a PHP tool in Java by hand, really I can't think of PHP libraries that don't also exist for Java as well...
发布评论
评论(2)
您无法像处理 Java 库那样从 Java 包装或扩展 PHP 代码,但您可以在服务器上调用 PHP 代码并使用您自己的 Java 应用程序的结果。请参阅如何从 Java 执行 PHP 脚本?
除此之外,我同意上面的评论。学习 PHP 或用 Java 重写您需要的代码部分可能会更容易。
在看到您的评论中所谈论的 PHP 工具后,用 Java 重写似乎不是一个好的选择。如果您从头开始创建一个网站(这意味着您还没有想要添加此内容的 Java 应用程序),那么 PHP 并不难学。除此之外,您还可以寻找与您现在正在查看的 PHP 工具执行相同操作的 Java 项目。
You can't wrap or extend PHP code from Java the way you would a Java library, but you might be able to call PHP code on your server and work with the results from your own Java application. See How can I execute a PHP script from Java?
Barring than that, I agree with the comment above. It might be easier to either learn PHP or rewrite the parts of the code that you need in Java.
After seeing in your comments what PHP tool you're talking about, rewriting in Java doesn't seem like much of an option. If you're starting a site from scratch (meaning you don't already have a Java application that you want to add this to) then PHP is not that hard to learn. Other than that, you could look for Java projects that do the same thing as the PHP tool you're looking at now.
好吧,如果您能告诉我们您的 PHP 工具/框架到底是做什么的,甚至可能给我们一个它的网站链接,那么我相信您会得到大量关于相应 Java 工具/框架的推荐,这将很有用。做同样的事情。我不认为你需要用 Java 手工重新制作一个 PHP 工具,我真的想不出 Java 中不存在的 PHP 库......
Well, it would be useful if you'd tell us what exactly your PHP tool/framework does, maybe even give us a link to it's site, then I'm sure you'll get tons of recommandations for corresponding Java tool/framework that does the same thing. I don't think you need to remake a PHP tool in Java by hand, really I can't think of PHP libraries that don't also exist for Java as well...