PHP global variable?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi All,

I asked this over in one of the php groups and got no response so I
thought I would bring it back to where the real experts are and ask again.

Not sure if this is possible or not. How can I have a global constant as
a part of my variable names. As an example, I want all the ZZZ to equal
"C10" in the  snippet of code below.

Why do I want to do this you ask? We are going to have anywhere from 60
to 100 drifters in the ocean sending back gps data and a table of that
data will be on a webpage. I am going to have separate files with PHP in
them for each unit to disseminate the date and build the tables. I
thought rather than having to create each script file and assign the
unique variables throughout the file I could just tell it once that it
is unit C10 like ZZZ = C10, save the page and then change the global and
save as the next unit name(C11). I hope I didn't present this query in a
confusing manner. I'm kind of new to PHP but am getting it to work so
far. Any help or ideas you can give me are greatly appreciated.


<This is only a snippet. Assume that there will be other places in the
file that require ZZZ to equal C10.>

$ZZZdataFile = "/DATA2/BUOY/ZZZdata.dat";
     if (!($fpZZZ = fopen($ZZZdataFile, "r")))
         exit("Unable to open $ZZZdataFile.");
     while (!feof($fpZZZ))
         // Assign variables to optional arguments
         $buffer = fscanf($fpZZZ, "%s %s %s %s %s %s",
            $ZZZdate $ZZZtime, $ZZZlat, $ZZZlon);
     fclose ($fpZZZ);


<This will appear as part of the table>

        <td><?php echo ("$ZZZlat"); ?></td>
        <td><?php echo ("$ZZZlon"); ?></td>
        <td><?php echo ("$ZZZdate"); ?></td>
        <td><?php echo ("$ZZZtime"); ?></td>

Patrick A. Smith  Assistant System Administrator
Ocean Circulation Group USF - College of Marine Science Phone: 727 553-3334

The trouble with doing something right the first time is that nobody
appreciates how difficult it was. - La Rochefoucauld

Re: PHP global variable?

Patrick wrote:
Quoted text here. Click to load it

Check again.  You did get an answer.  Use a database instead.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline