[SOLVED] global variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joostschouten
Forum Newbie
Posts: 2
Joined: Wed Mar 10, 2004 10:50 am
Location: the Netherlands

[SOLVED] global variables

Post 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
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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]
joostschouten
Forum Newbie
Posts: 2
Joined: Wed Mar 10, 2004 10:50 am
Location: the Netherlands

Post 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
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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. ;)
Post Reply