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

谁说我不能喝 提交于 2019-11-27 18:55:26

问题


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?


回答1:


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.




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/6327243/is-php-or-php-based-web-framework-stateful-or-stateless

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!