<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
|
edit
The name of the argument |
|
type
string, optional
|
edit
The type of the argument
|
|
required
boolean, optional
|
edit
is argument required or not |
|
default
any, optional
|
edit
default value of the argument |
|
displayName
string, optional
|
edit
name to display (only used by components) |
|
hint
string, optional
|
edit
hint to the argument (only used by components) |
|
passBy
string, optional
|
edit
should the argument passed as reference (default) or as a value |
reference |
Examples
edit<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;
}
Related System Properties / Environment Variables
- LUCEE_SUPPRESS_WS_BEFORE_ARG - A boolean value. If enabled, Lucee suppresses whitespace defined between the cffunction starting tag and the last cfargument tag. This setting is ignored when there is different output between these tags as whitespace
Type: boolean, Default: true
See also
- Components (CFCs)
- <cfcomponent>
- <cffunction>
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)