同一PHP脚本的实例可以交叉通信吗? [英] Can instances of the same PHP script cross communicate?

查看:74
本文介绍了同一PHP脚本的实例可以交叉通信吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我假设对于每个页面请求,网络服务器(例如Apache)都会在内存中创建脚本的新实例。这些实例在运行时可以相互通信吗?并传递数据吗?

I'm assuming that for every page request, the webserver (eg. Apache) creates a new instance of a script in memory. Can these instances communicate with each other while running? and pass data too?

推荐答案

如果要在PHP脚本之间传递数据,建议使用memcached或数据库。或许还有APC。

If you want to pass data between scripts in PHP I suggest using either memcached or a database. Or possibly APC.

如果脚本属于同一会话,则理论上它们可以通过该会话进行通信,但这在大多数情况下实际上是一种单向通信,因为仅一个脚本可以随时访问该会话(session_start()锁定会话,直到该脚本隐式或显式结束会话为止。)

If the scripts belong to the same session, they could theoretically communicate via the session but this would be effectively a one-way communication in most cases because only one script can access the session at any one time (session_start() locks the session until that script ends the session implicitly or explicitly).

这篇关于同一PHP脚本的实例可以交叉通信吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆