开发者

Is PHP or PHP based web framework stateful or stateless? [closed]

开发者 https://www.devze.com 2023-03-12 17:02 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

The community reviewed whether to reopen this question 9 months ago and left it closed:

Original close reason(s) were not resolved

Along the same lines that for java centric applications, Play framework is stateless and lift framework is stateful as is any servl开发者_开发技巧et 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 by itself has no state. Each request is completely unique. It's very close to the bare metal of HTTP in this regard.

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.


It is not all about Java or PHP. HTTP is a stateless protocol.

To make it stateful, the developer (programmer) has to make sure that all relevant information is stored and make sure that all relevant information is read back in when the script is called upon.

Most of the servers provide session management for stat management.

As to why stateless - stateful session add significant memory and performance overhead see:

models-with-persistent-state-between-http-requests


The only 'state' thing in a web application is what's stored persistently somewhere (like a database), the web request-response flow is stateless. It takes from or puts to the persistent storage so it behaves like as if it's stateful. IMHO, session and cookie are included in this persistent storage.

0

精彩评论

暂无评论...
验证码 换一张
取 消