Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199908

[PHP3] Global function doesn't keep its value From: Eddy Ng (eng <email protected>)
Date: 08/30/99

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

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