Skip to main content
March 26, 2011
Question

Re: cgi.SERVER_NAME vs SERVER_NAME

  • March 26, 2011
  • 2 replies
  • 953 views

Is there a difference betweencgi.SERVER_NAME vs SERVER_NAME?

thanks!

    This topic has been closed for replies.

    2 replies

    Inspiring
    March 26, 2011

    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.

    talofer99
    Inspiring
    March 26, 2011

    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 :

    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec09af4-7fdf.html#WSf01dbd23413dda0e60ff903612013e997d9-7feb