
Question:
I was reading something about SuplerGlobals like $_SERVER or (see more detail <a href="http://php.net/manual/en/language.variables.superglobals.php" rel="nofollow">PHP Manual Superglobals</a>) the other day, now, I'm asking me:
Is it possible to implement own SuperGlobals? Beside of Constants...
So for example user A writes something in the Variable which, if User B is calling it can see. Something like a server wide Session Variable or something.
Please don't be to hard, if its a silly question :) I know there are couple of ways outside, like SQL, Xml and Stuff, but maybe...
Answer1:PHP doesn't have context which can be shared between users. You should some replacement like SQL server or file. You may also check some extensions like <a href="http://php.net/manual/en/book.memcache.php" rel="nofollow">memcache</a> which might help you achieve your goal.
Answer2:Your whole idea of PHP superglobals it wrong.<br /> These variables are always available in terms of just one script runtime, no the whole site.
Answer3:<blockquote>
I was reading something about SuplerGlobals like $_SERVER or (see more detail PHP Manual Superglobals) the other day, now, I'm asking me:
Is it possible to implement own SuperGlobals? Beside of Constants...
</blockquote>Yes it is possible if you've got the <a href="http://php.net/manual/en/runkit.configuration.php" rel="nofollow">PHP runkit</a> extension.
<blockquote>So for example user A writes something in the Variable which, if User B is calling it can see
</blockquote>That's not what superglobals do - they are variables which exist in global scope (i.e. for the duration of an instance of a script).
If you want to share data between different invocations then you need to send it to your storage tier or (in the case of data for a single client) out to the browser.
Since what you are describing here is effectively a shared session, then the sensible place to implement this would be in the session handler.
Answer4:This is not possible, you can only see your own session data.
To achieve this you would need to store the data somewhere else. in text files or in a MySQL database would be the most common.
Answer5:i suppose you can use (asterix)export yourvar="something"(asterix)
and to receive it using getenv
sry, dont know how to embed asterix=`, but it is better to avoid it...
If you use apache following could be used: <a href="http://php.net/manual/en/function.apache-setenv.php" rel="nofollow">http://php.net/manual/en/function.apache-setenv.php</a>
same idea, enveroinment variable