用于企业 Web 应用程序的 PHP 与 Java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20923372/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP vs Java for enterprise web applications
提问by watery
Is it possible to write enterprise web applications in PHP as it is in Java (with Java EE stack of technologies)? I know just a bit of PHP and I've always seen it like a request-process-response programming/scripting language with no objects staying alive on the server (like @Stateful
ejbs) after the script has finished its execution.
是否可以像在 Java 中一样用 PHP 编写企业 Web 应用程序(使用 Java EE 技术堆栈)?我只知道一点 PHP,我一直认为它是一种请求-处理-响应编程/脚本语言,@Stateful
脚本完成执行后,服务器上没有任何对象(如ejbs)保持活动状态。
To put it in another way: can the same web application be implemented in Java and in PHP? Or is one of the two languages more powerful than the other?
换句话说:可以用 Java 和 PHP 实现相同的 Web 应用程序吗?或者这两种语言中的一种比另一种更强大吗?
Edit: let me clarify my question: I already know Java and have some experience in enterprise web applications. I want to know if PHP is equally powerful (in language structure, in today available frameworks, and so forth) to make the same complex applications that can be done in Java.
编辑:让我澄清一下我的问题:我已经了解 Java 并且在企业 Web 应用程序方面有一些经验。我想知道 PHP 是否同样强大(在语言结构中,在当今可用的框架中,等等)来制作可以在 Java 中完成的相同复杂应用程序。
回答by Kayaman
Not more powerful in the sense that you could write something in Java that would be impossible to replicate in PHP. I'm not familiar with PHP, but there's most likely similar frameworks and libraries that have been created for PHP that exist already in Java (such as an ORM framework like JPA).
在您可以用 Java 编写一些在 PHP 中无法复制的东西的意义上,并不是更强大。我不熟悉 PHP,但很可能为 PHP 创建的类似框架和库已经存在于 Java 中(例如像 JPA 这样的 ORM 框架)。
Stateful EJBs aren't that special (and not that common either). You can readily store information in the session whether you're using Java or PHP.
有状态 EJB 没有那么特别(也不那么常见)。无论您使用 Java 还是 PHP,您都可以轻松地在会话中存储信息。
This isn't really a suitable question for SO either, since programming languages are different and frameworks are different and you'll never find the "best" something, because that doesn't really exist.
这也不是一个真正适合 SO 的问题,因为编程语言不同,框架不同,你永远找不到“最好”的东西,因为那并不存在。
Solution: learn both.
解决办法:两者都学。