Copy link to clipboard
Copied
Is there a difference betweencgi.SERVER_NAME vs SERVER_NAME?
thanks!
Copy link to clipboard
Copied
CF is VERY flexible with its variable origin, for good and some time for bad (if u are not careful)
There for cgi.SERVER_NAME is the same as SERVER_NAME …
AS LONG as there is no other declared variable named SERVER_NAME
Same go for form/url variables
Look at the following example:
<!--- Define URL . INFO --->
<cfparam name="url.info" default="url.info">
<!--- DEFINE FORM . INFO --->
<cfparam name="form.info" default="form.info">
<cfoutput>
<!--- NOTICE THE OUT PUT IS OF THE URL . INFO --->
info - #info#<BR />
<cfset info = "I just added a value ">
<!--- NOW THE VALUE IS OF THE VARIABLE WE SET --->
info - #info#<BR />
<!--- SAME GOES FOR SERVER_NAME --->
cgi.SERVER_NAME - #cgi.SERVER_NAME#<BR />
SERVER_NAME - #SERVER_NAME#<BR />
<cfset SERVER_NAME = "I just placed a new value ...">
SERVER_NAME - #SERVER_NAME#<BR />
</cfoutput>
Here is a good list of the order :
Copy link to clipboard
Copied
talofer99 gave you a reference to the order in which CF looks for scopes when you don't scope your variables. While this allows you to be lazy with your typing, it will slow down your app. If this app is going to live on a busy server, that could be relevent.