By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

PHP Server-based variables/flags

P: 7

I have been working on a php script. In the script, fast reading/writing is necessary to a variable on the server side. It is a one bit flag. Right now, I have been using a text file to write the value 0 or 1 to it, but it isn't very efficient. I was wondering if there is a better way to do this other than the text file or a database. I don't want to add the extra requirement of a database to my program.

Thanks a lot!
Aug 5 '07 #1
Share this Question
Share on Google+
4 Replies

P: 228
It is a one bit flag. Right now, I have been using a text file to write the value 0 or 1 to it, but it isn't very efficient.
Thanks a lot!
you need to give as better idea on what you are trying to do

normally you can store variables in the SESSION which automaticly save registered variables for you
you can try to use mysql if you want to share it between a few users or serialize session

ps: text files are very efficient thats just a data and it depends how u handle it

all depends what you trying to achive

Aug 5 '07 #2

P: 7
Thank you for your reply

What I have done is created an AJAX-based application which sends off an int to the server. 0 queries the bit, 1 is set the bit to true, and 2 sets the bit to false. The bit is queried every 300 milliseconds by every client connected to the server. All of these clients need to have access to the same bit. So what I was wondering is if there is any way to do this other than through text files. Maybe there is something similar to a cookie on the server? I REALLY don't want to use a MySQL database, and it just seems like a waste to use a text file just for a 0 or 1.

Thanks again!
Aug 5 '07 #3

Expert 5K+
P: 5,821
Heya, tromboneman. Welcome to TSDN!

If your server isn't storing the data SOMEWHERE on the hard drive, where is it going to store it? There is no mystical bit bucket floating over Silicon Valley; that's just the smog :)

Of all your options, storing the value in a text file is actually the *most* efficient. It just also happens to be the least scalable.

You could store the value in a database (which gets saved into a file on the hard drive).

Or you could store the value in $_SESSION (which gets saved into... a file on the hard drive!).
Aug 5 '07 #4

P: 7
Okay, thank you. I just assumed there would be a way to store temporary variables in memory. Thank you for your help!
Aug 5 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.