php在不同的用户/会话之间共享变量 [英] php share variable among different users/sessions

查看:78
本文介绍了php在不同的用户/会话之间共享变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为访问系统的所有不同用户/客户端提供一个具有相同值的变量.

i want to have a variable that has the same value for all the different users/clients accessing the system.

变量的值也必须是可修改的.

also the variable's value has to be modifiable.

就像任何一个用户更改了值一样,更改也必须反映给所有其他用户.

like if any one user changes the value, the change has to get reflected to all other users too.

推荐答案

将变量存储在共享空间中,例如

Store the variable in a shared space like

  • 一个文件

  • A file

数据库记录(最容易实现锁定,请参见下文)

A database record (easiest for implementing locking, see below)

内存缓存存储区

您可以在此处轻松地对其进行修改.当多个用户尝试编辑比赛条件时,您可能需要使用某种锁定机制同时值.

you can easily modify it there. You may need to use some sort of locking mechanism to prevent race conditions when multiple users try to edit the value at the same time.

这篇关于php在不同的用户/会话之间共享变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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