Skip to content

Instantly share code, notes, and snippets.

View bharat20185's full-sized avatar

Bharat Patel bharat20185

View GitHub Profile
<cfscript>
variables.myArr = ["John", "Doe", "Tom"];
loop array="#variables.myArr#" item="variables.ele" {
writeOutput(variables.ele)
}
</cfscript>
<cfscript>
variables.heroes = [
{
'name': 'Iron Man',
'movies': 11
},
{
'name': 'Captain America',
'movies': 7
}
<cfscript>
variables.hero = {
'name': 'Iron Man',
'movies': ['Iron Man','Iron Man 2','The Avengers','Iron Man 3','Avengers: Age of Ultron','Captain America: Civil War','Spider-Man: Homecoming','Avengers: Infinity War','Avengers: Endgame']
};
variables.hero.each(function(key, value, struct){
writeDump(arguments);
});
</cfscript>
<cfscript>
variables.heroQuery = queryNew(
'name,movies',
'varchar,varchar',
[
{
'name': 'Iron Man',
'movies': 'Iron Man,Iron Man 2,Iron Man 3'
},
{
<cfscript>
variables.heroes = "Nick Fury, Iron Man, Vision, Caption America, Thor";
variables.heroes.each(function(hero, index, list){
writeOutput(index & '. ' & hero);
writeOutput('<br />');
});
</cfscript>
<cfscript>
function printMe() {
return arguments?.name;
}
dump(printMe())
dump(printMe(name = 'Bharat Patel'))
</cfscript>
<cfscript>
function printMe(
required string name
) output="true" {
writeOutput("<h1>#name#</h1>")
return;
}
</cfscript>
<cfscript>
function sendMail(
required string fromAddress,
required string toAddresses,
required string subject,
required string content,
numeric priority = 1, // urgent
string ccAddresses,
string bccAddresses,
array attachments