I have a PHP file, say foo.php
and I am running multiple instances of the same PHP file.
php foo.php&
php foo.php&
php foo.php&
php foo.php&
I need a variable bar
inside foo.php
such that if bar is changed in one running instance, it can be updated in other instances as well.
How can I achieve this?
I tried File Processing - storing value of bar
in some random file, and reading it from there and updating the same.
From Question - " Share variables/memory between all PHP processes ", I got to know about gearman . But this seems to be using an aeroplane instead of using a bike!
i'm assuming you want to share the value of variable bar across all instances and sessions (just in-case), in that case the ideal thing will be to have the variable values stored in a dedicated file on the server and read by the variable when called. a similar trick is used in game development where DLL files are used as shared libraries..
i will further suggest having a script read the value of bar from the server probably by implementing a timer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.