Creates a CFML object, of a specified type.
The tag syntax depends on the object type. Some types use the
type attribute; others do not.
<cfobject name="">
cfobject(name="");
com
component
corba
java
dotnet
webservice
create
connect
inproc
local
remote
ior
nameservice
false
true
false
tcp
tcp
http
false
true
false
Here created the simple component with user defined function name as multiply.
<cfcomponent>
<cffunction name="multiply" access="public" returnType="numeric">
<cfargument name="FirstNum" type="numeric">
<cfargument name="SecondNum" type="numeric">
<cfretrun arguments.FirstNum * arguments.SecondNum>
</cffunction>
</cfcomponent>
Calling the above multiply function by using cfobject tag based code.
<cfobject name="multiplyObj" type="component" component="multiply">
<cfoutput>
#multiplyObj.multiply(1,2)#
</cfoutput>
Expected Result: 2
Calling the above multiply function by using cfobject script based code.
<cfscript>
cfobject(name="multiplyNum" type="component" component="multiply"){
writeOutput(multiplyNum.multiply(6,7));
}
</cfscript>
Expected Result: 42
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.