PHP 或基于 PHP 的 Web 框架是有状态的还是无状态的?
与以 Java 为中心的应用程序相同,Play 框架是无状态的,lift 框架是有状态的,就像任何 servlet 或 Java EE 容器(如 Tomcat 或 GlassFish 是有状态的)一样,是 PHP Web 框架(如 zend 或 cake php 是无状态的或有状态的)和为什么?
Along the same lines that for java centric applications, Play framework is stateless and lift framework is stateful as is any servlet or Java EE container like Tomcat or GlassFish is statefull, is PHP web framework like zend or cake php stateless or stateful and why?
推荐答案
PHP 本身没有状态.每个请求都是完全唯一的.在这方面,它非常接近 HTTP 的裸机.
PHP by itself has no state. Each request is completely unique. It's very close to the bare metal of HTTP in this regard.
要在此基础上实现状态,您可以使用会话、数据库、共享内存、文件或其他任何以某种方式保留状态的东西.Zend 或 Cake 等框架为这些机制提供了抽象,使其在不同程度上显得开箱即用.PHP 从来没有真正保持状态.
To implement state on top of that you can use sessions, databases, shared memory, files or anything else that somehow retains state. Frameworks like Zend or Cake offer abstractions for these mechanisms that make it appear stateful out of the box to varying degrees. PHP is never truly keeping state though.
相关文章