是否可以将java代码自动转换为PHP?
有没有java代码转php的工具?我有java库的源代码,我需要它转换为php。
Is there are tools for converting java code to php? I have source code of java library and I need it to convert to php.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
可以自动转换它。这称为源到源编译器。通常,当您编译软件时,解析器会构建一个抽象语法树并将其转换为目标机器语言代码。但也可以让编译器将其转换为另一种高级(可编译)语言。
Java 是一种强类型语言,而 PHP 不是,因此源到源编译器很少,并且代码转换过程不完整。然而,话虽如此,有一个相当不错的免费演示,位于:http://javatophp.com
It is possible to automatically convert it. This is called a source to source compiler. Normally when you compile software, the parser will build an abstract syntax tree and convert this into the target machine language code. But it is just as possible to have a compiler convert this into another high level (compilable) language.
Java is a strongly typed language, and PHP is not, so source to source compilers are rare and the code conversion process is incomplete. However this said, there is a reasonably good one with a free demo at: http://javatophp.com
自动 - 不,现在。也许将来。别花时间了,写新代码吧兄弟。
Automatically - No. Now. Maybe in future. Don't spend time, write new code bro.
我认为目前还没有这样的解决方案。
您可以尝试使用 php-java 桥接器,它允许您从 PHP 中调用 java 代码:
http://php-java-bridge.sourceforge.net/pjb/
Zend Server 还提供了一个桥
I don't think there is a solution like this currently.
You might try using a php-java bridge that would allow you to call the java code from within PHP:
http://php-java-bridge.sourceforge.net/pjb/
Zend Server also provides a bridge
Facebook 的 5 人团队花了 18 个月的时间编写了将 PHP 到 C++(参见:HipHop)。目前还没有这样的从 Java 转换为 PHP 的软件。
答案是:是的...如果您有一年半的专业程序员团队,这是可能的:)
否则,您手动重写它(我认为,这是您的选择)。
Team of 5 folks at Facebook have spent 18 month to write sofrware that converts PHP to C++ (meet: HipHop). There is no such software for transforming from Java to PHP yet.
The answer is: yes... it is possible if you have year and a half and team of pro programmers :)
Otherwise, you rewrite it manually (I think, this is your choise).
Java 有很多方面无法用 PHP 表达。类型安全就是其中之一。对我来说,这听起来像是一个愚蠢的差事。如果您想朝相反的方向前进,这个问题可能会引起一些兴趣。
There are lots of aspects of Java that cannot be expressed in PHP. Type safety for one. This sounds like a fool's errand to me. If you were looking to go in the opposite direction the question might have some interest.