472,143 Members | 1,299 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

Global variables - application variables vs include file

What are the best methods for using global constants and variables?

I've noticed that many people put all global constants in a file and
include that file on every page. This is the best way of doing it - is
it not? Once the application has loaded the page it is cached and is
immediately available for other pages.

With global variables - the best thing to do would be to use
application variables - so long as there weren't too many declared.
Is there another (easy) way of using global variables apart from using
application variables?

Jul 19 '05 #1
1 4203
CJM
Yes, Application variables are a good use for global variables. And yes, too
many application variable can eventually have an impact on the server, so
you must be reasonable.

Things like connection strings, paths and other CONSTANTS are ideal fodder
for application variables. So are VARIABLES that need to be available to all
users (ie. across all sessions), eg. a Hit-Count.

However, I'd query what you mean by 'global variables'. You could be meaning
a variable that is 'global' for one user/one session. In this case, Session
variables might be in order.

To take this argument further, you might choose to avoid session variables
(because they can have a hit on the server), in which case you can use DBs
and Querystrings to maintain state.

I hope this all makes some sense...! lol

Chris
"mark4asp" <ma****************@ntlworld.com> wrote in message
news:5u********************************@4ax.com...
What are the best methods for using global constants and variables?

I've noticed that many people put all global constants in a file and
include that file on every page. This is the best way of doing it - is
it not? Once the application has loaded the page it is cached and is
immediately available for other pages.

With global variables - the best thing to do would be to use
application variables - so long as there weren't too many declared.
Is there another (easy) way of using global variables apart from using
application variables?

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Michael | last post: by
6 posts views Thread by Andrea Williams | last post: by
22 posts views Thread by fd123456 | last post: by
8 posts views Thread by Giorgio | last post: by
7 posts views Thread by zeecanvas | last post: by
3 posts views Thread by Stephen Kay | last post: by
15 posts views Thread by =?Utf-8?B?UGF0Qg==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.