Page 1 of 1

[SOLVED] global variables

Posted: Wed Mar 10, 2004 10:50 am
by joostschouten
hi,

I'm am new to PHP. I have a JAVA application for which I use a custom 500 error page made with PHP. To notify me whenever my Servlet engine is down.

I successfully made the page sent me an email. However, I wish to store some variables globally (servletContext in JAVA) so the page remembers when the last email was sent. This to prevent hundreds of emails from being sent once the server is down.

My question is: How can I store variables globally so all PHP pages, all clients and all requests can use them.

Example code would very much be appreciated.

Kind regards,
Joost Schouten

Posted: Wed Mar 10, 2004 10:53 am
by m3mn0n
How about you use a MySQL or textfile (I recommend this), to store the last date/time of the last email sent. Then before the error email is sent, you can check the current time againts the one in the file.

If hasn't been x minutes or hours, or whatever, you can deny the email from being sent. :)


Helpful links:
php.net/[php_man]filesystem[/php_man]
php.net/[php_man]date[/php_man]

Posted: Wed Mar 10, 2004 11:00 am
by joostschouten
Ok, so there is no such thing in PHP as a server maintained variable?

A small text file is what I'll set up then.

Thank you,
Joost

Posted: Wed Mar 10, 2004 11:04 am
by m3mn0n
No problemo.

Well in a sense, no. But with the power PHP gives us, you could create a server maintained variable, such as the one your creating now. ;)