Page 1 of 1

Does PHP support user assigned Superglobal variables?

Posted: Wed Oct 16, 2002 7:13 pm
by somekid
Let me explain what I'm trying to do...

This is for a call center, and, among other thing, the progam is to track technical support calls. Each tech has their own unique login, and, when logged in, a session object is created w/their info.

The call log has information it pulls out of the database that doesn't change very often, like the problem type (in a dropdown box) and the solutions according to the problem type (also a dropdown box). I was hoping that, instead of using a "SELECT * FROM problemCode" on each page display I could just create a global (or super global from what PHP calls them it seems) array for ALL scripts to see, so there is only one select statement. This way MySQL can use it's time searching through call logs, or things that are actually changing. If the problemCode table is to be updated, then the array would be too.

Is this possible?

from "test1.php", the code
<?php
$GLOBALS['temp'] = "some text";
echo $GLOBALS['temp'];
?>

is fine, but after running that, then runing "test2.php"

<?php
echo $GLOBALS['temp'];
?>

is blank. Does PHP allow 'super global' variables assigned by the user?

Any suggestions, comments, tips, whatever would be greatly appreciated, thanks!

Posted: Wed Oct 16, 2002 7:20 pm
by levi_501_dehaan
what im getting here is you want to pass the same variables throught your scripts? if so then
I do believe that you can pass variables using session
ie
$someinfo = "someinformation you want everywhere";
session_register("someinfo");

then on any other page that has session_start(); at the top (probably all your pages if your already using sessions)

you can call your session variable using
$someinfo = $_SESSION["someinfo"];

you can assign stuff to session too without session register
$_SESSION["information"] = "data and stuff";
and call it with

$data = $_SESSION["information"];

try it out and let me know if it works.
-=Levi=-

Posted: Wed Oct 16, 2002 7:36 pm
by somekid
I want to pass the same variable througout my scripts for ALL users, where I am using $_SESSION['tech'] as an object w/variables and functions related to the individual tech. All the techs will share some information from the database, like the problem types, and I didn't want to put that in a session object so that there are 50 sessions, and all of them have the same information in them, if that makes sense.

Posted: Wed Oct 16, 2002 11:11 pm
by volka

Posted: Thu Oct 17, 2002 2:03 pm
by somekid
volka, thanks for the links (and for not flaming me because I didn't search).

I hadn't thought of using serialize() and unserialize() to save an objects state, which would work perfectly to emulate a global object, and that is exactly what I was looking for.

Thanks again!

Posted: Thu Oct 17, 2002 7:24 pm
by infolock
i can't wait to be able to say/do all that and know what i'm talking about, all at the same time 8O

GIB ME TIME OBI-1, GIVE ME TIME!@#!@# :twisted:

Posted: Thu Oct 17, 2002 11:07 pm
by volka
Image
"I prefer tongue-tied knowledge to ignorant loquacity." - Cicero 55 B.C.
"Say not always what you know, but always know what you say." - Claudius 10 B.C. - 54 A.D.

and there are of course all those excellent tips from lord Polonius
http://the-tech.mit.edu/Shakespeare/hamlet/hamlet.1.3.html

;)