php3-list | 199908

RE: [PHP3] Global function doesn't keep its value From: raschn <email protected>
Date: 08/31/99

I had this same problem yesterday, and I was able to pass a value from one
page to another like so:

<a href=\"Process.php3?barcode=$machinename\">$machinename</a>

The variable $barcode was then equal to the contents of $machinename, and I
was able to use the value of $barcode in my code.

Nate
 

-----Original Message-----
From: Richard Lynch [mailto:rlynch <email protected>]
Sent: Monday, August 30, 1999 4:45 PM
To: Eddy Ng; php3 <email protected>
Subject: Re: [PHP3] Global function doesn't keep its value

http is stateless.

global only means for the duration of a script's run, across various
functions. Not forever.

You will need to store data into a database or a file or shared memory to
make it persist across http connections.
[Or encode it into the script for something this easy.]

What is the real end use for this?

At 10:52 AM 8/30/99 -0600, you wrote:
>I wrote this simple script and couldn't get it to work as expected. The
>script name is globaltest.php3. I expected everytime I executed this
>script, it will increment $myglobal by one. Therefore, I should see
>"myglobal is now 1", the next time I click "here", I should get
>"myglobal is now 2", and so on, and so on. But instead, I kept getting
>"myglobal is now 1" all the time. Any idea on what's wrong with the
>script? BTW, I already limit my apache httpd child process to maximum of
>2. Therefore, if the request hits different process everytime, I
>expected it to at least increment $myglobal after the third click to
>"here".
>
><HTML>
><BODY>
>
><H1> myglobal is now
>
><?PHP
>$myglobal = 0;
>
>function incrementglobal()
>{
> global $myglobal;
>
> $myglobal = $myglobal + 1;
>}
>
>incrementglobal();
>
>print ($myglobal);
>
>?>
>
></H1> <br>
>
>Click <A HREF=globaltest.php3> here</A> to increment myglobal again
>
></BODY>
></HTML>
>
>
>Any help will be appreciated.
>
>Thanks,
>Eddy Ng
>
>
>Attachment Converted: "C:\maildrop\eng.vcf"
>--
>PHP 3 Mailing List <http://www.php.net/>
>To unsubscribe, send an empty message to php3-unsubscribe <email protected>
>To subscribe to the digest, e-mail: php3-digest-subscribe <email protected>
>To search the mailing list archive, go to:
http://www.php.net/mailsearch.php3
>To contact the list administrators, e-mail: php-list-admin <email protected>

-- 
"TANSTAAFL"  Websites I have built:
CHaTMusic.com      EmphasisEntertainment.com     L-I-E.com
JadeMaze.com       CatCatalani.com               MGMH.com
AstraKelly.com     OlivierLedoux.com

-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>

-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>