如何在 Classic ASP 中将变量设为静态(或“全局")? [英] How can I make a variable static (or "global") in Classic ASP?

查看:24
本文介绍了如何在 Classic ASP 中将变量设为静态(或“全局")?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的变量设为静态或全局"——因此与 .NET 中的静态效果相同;每个访问它的会话都会得到相同的结果,如果一个会话修改它,它也会影响其他所有人.

I want to make my variable static or "global" - so the same effect as static in .NET; every session that accesses it gets the same result, and if one session modifies it it affects everyone else too.

如何在 Classic ASP 中实现这一点?

How can I achieve this in Classic ASP?

推荐答案

如果你想拥有一个可在应用程序范围内访问的变量,你可以使用应用程序对象.请务必使用 Application.Lock/Unlock 以防止出现任何问题.

If you want to have a variable that is accessible application wide, you can use the application object. Be sure to use Application.Lock/Unlock to prevent any problems.

Application.Lock
Application("MyVariable") = "SomeValue"
Application.Unlock

这篇关于如何在 Classic ASP 中将变量设为静态(或“全局")?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆