Search code examples
phpscriptingwebservercommunicationdata-transfer

Can instances of the same PHP script cross communicate?


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?


Solution

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

    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).