<cfargument>

Defines a parameter that may be sent when the function is called.

When used, cfargument tag(s) must be the first tags used within the cffunction.

This tag cannot have a body.

This tag is also supported within <cfscript>

<cfargument name=string type=string required=boolean default=any displayname=string hint=string passby=reference|value >
Attribute Description Default
name
string, required

The name of the argument

type
string, optional

The type of the argument

  • array
  • binary
  • boolean
  • date
  • guid
  • numeric
  • query
  • string
  • struct
  • uuid
  • variableName
required
boolean, optional

is argument required or not

default
any, optional

default value of the argument

displayname
string, optional

name to display (only used by components)

hint
string, optional

hint to the argument (only used by components)

passby
string, optional

should the argument passed as reference (default) or as a value

reference

Examples

<cfoutput>
 	<cffunction access="private" name="add">
		<cfargument name="arg1" type="Numeric" required />
		<cfargument name="arg2" type="Numeric" required />
	 	<cfreturn arg1 + arg2 />
	</cffunction>
	<cfdump var="Define function Using tag.It returns :#add(4,2)#" />
</cfoutput>
writeDump("Define function using cfscript. It returns: "&add(2,3));
		public function add(required numeric arg1,required numeric arg2){
			return arg1+arg2;
		}

See also