mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-26 23:23:55 +00:00
10 KiB
10 KiB
language | contributors | filename | |||
---|---|---|---|---|---|
ColdFusion |
|
LearnColdFusion.cfm |
ColdFusion is a scripting language for web development. Read more here.
<!--- Comments start with "<!---" and end with "--->" --->
<!---
Comments can
also
span
multiple lines
--->
<!--- CFML tags have a similar format to HTML tags. --->
<!--- Variable Declaration: Variables are loosely typed, similar to javascript --->
<cfset myVariable = "myValue" />
<cfset myNumber = 3.14 />
<!--- Displaying simple data --->
<!--- Use <cfoutput> for simple values such as strings, numbers, and expressions --->
<cfoutput>#myVariable#<br /></cfoutput> <!--- myValue --->
<cfoutput>#myNumber#<br /></cfoutput> <!--- 3.14 --->
<hr />
<!--- Declaring complex variables --->
<!--- Declaring an array of 1 dimension: literal or bracket notation --->
<cfset myArray1 = [] />
<!--- Declaring an array of 1 dimension: function notation --->
<cfset myArray2 = ArrayNew(1) />
<!--- Outputting complex variables --->
<cfdump var="#myArray1#" /> <!--- An empty array object --->
<cfdump var="#myArray1#" /> <!--- An empty array object --->
<!--- Operators --->
<!--- Arithmetic --->
<cfoutput>#1 + 1#<br /></cfoutput> = 2
<cfoutput>#10 - 8#<br /></cfoutput> = 2
<cfoutput>#1 * 2#<br /></cfoutput> = 2
<cfoutput>#10 / 5#<br /></cfoutput> = 2
<cfoutput>#12 % 5#<br /></cfoutput> = 0
<hr />
<!--- Comparison --->
<cfoutput>#1 eq 1#<br /></cfoutput> <!--- TRUE --->
<cfoutput>#15 neq 1#<br /></cfoutput> <!--- TRUE --->
<cfoutput>#10 gt 8#<br /></cfoutput> <!--- TRUE --->
<cfoutput>#1 lt 2#<br /></cfoutput> <!--- TRUE --->
<cfoutput>#10 gte 5#<br /></cfoutput> <!--- TRUE --->
<cfoutput>#1 lte 5#<br /></cfoutput> <!--- TRUE --->
<hr />
<!--- Control Structures --->
<cfset myCondition = "Test" />
<cfif myCondition eq "Test">
<cfoutput>#myCondition#</cfoutput>
<cfelseif myCondition eq "Production">
<cfoutput>#myCondition#. Proceed Carefully!!!</cfoutput>
<cfelse>
myCondition is unknown
</cfif>
<hr />
<!--- Loops --->
<cfloop from="0" to="10" index="i">
<cfoutput>#i# <br /></cfoutput>
</cfloop>
<hr />
Further Reading
The links provided here below are just to get an understanding of the topic, feel free to Google and find specific examples.