cfm 页面中局部变量的范围?
Scope of a Local variable in a cfm page?
以下内容在 test.cfm
页面上:
<cfscript>
Local.myString = "Hello";
</cfscript>
myString
的范围是什么?它会在 cfm
页面的其他部分可见,还是仅在定义它的 <cfscript>
标签之间可见?
在函数外部,该赋值设置了一个变量 variables.local.myString
,变量作用域的作用域规则有详细记录:About scopes: variables。来自文档:
The default scope for variables of any type that are created with the
cfset and cfparam tags. A Variables scope variable is available only
on the page on which it is created and any included pages (see also
the Caller scope).Variables scope variables created in a CFC are
available only to the component and its functions, and not to the page
that instantiates the component or calls its functions.
本地范围同样是该页面上的文档,顺便说一句。
在对语言有疑问时,查阅文档始终是开始的好地方。
以下内容在 test.cfm
页面上:
<cfscript>
Local.myString = "Hello";
</cfscript>
myString
的范围是什么?它会在 cfm
页面的其他部分可见,还是仅在定义它的 <cfscript>
标签之间可见?
在函数外部,该赋值设置了一个变量 variables.local.myString
,变量作用域的作用域规则有详细记录:About scopes: variables。来自文档:
The default scope for variables of any type that are created with the cfset and cfparam tags. A Variables scope variable is available only on the page on which it is created and any included pages (see also the Caller scope).Variables scope variables created in a CFC are available only to the component and its functions, and not to the page that instantiates the component or calls its functions.
本地范围同样是该页面上的文档,顺便说一句。
在对语言有疑问时,查阅文档始终是开始的好地方。