Skip to main content
Inspiring
March 19, 2009
Question

cfset vs cfparam

Hi guys,
Can you tell me in simple short english the difference between cfset and cfparam?
    This topic is closed to new replies. Start a new post to keep the conversation going.

    8 replies

    Participating Frequently
    March 21, 2009
    Hey this should not be tough:
    CFSET - this tag will overwrite a variable to the value specified
    CFPARAM - if the variable specified already exists then leave it alone otherwise it creates and set it to the value of the DEFAULT parameter.
    Translate
    Inspiring
    March 21, 2009
    Semaphorians wrote:
    > Hey this should not be tough

    If the explanations provided are "not good enough", they should just read the documentation.
    Translate
    Inspiring
    March 19, 2009
    > Not good enough....

    You've been reading "How to Win Friends and Influence People", I see.

    You could - of course - just go read the docs. They're fairly explicit on
    what each does:

    <cfset>
    http://livedocs.adobe.com/coldfusion/8/Tags_r-s_17.html


    <cfparam>
    http://livedocs.adobe.com/coldfusion/8/Tags_p-q_01.html

    CFSearching (you people sure do have weird names) gave you a good start,
    and explaining how 90% of people probably utilise the differences between
    <cfset> and <cfparam>.

    --
    Adam
    Translate
    Inspiring
    March 19, 2009
    Adam Cameron wrote:
    > you people sure do have weird names

    I have never read your bio. But your dry wit makes one suspect you are British. (No that is not an insult. I just enjoy a dry sense of humor ;-)
    Translate
    emmim44Author
    Inspiring
    March 19, 2009
    Not good enough....
    Translate
    Inspiring
    March 22, 2009
    quote:

    Originally posted by: emmim44
    Not good enough....

    In what way?
    Translate
    Inspiring
    March 19, 2009
    There are several differences.

    Loosely put, the primary difference is that cfparam sets the value of a variable _only_ if that variable does not exist. Whereas cfset always sets the value of a variable. ie If the variable exists, it overwrites the existing value. If it does not exist, it creates one.

    But again, there are several differences. That is only one.
    Translate