Get the name a function was called as, equivalent to CFML's getFunctionCalledName()

Asked
Active3 hr before
Viewed126 times

5 Answers

calledfunction
90%

Meta Stack Overflow , Stack Overflow Public questions & answers , Stack Overflow help chat , Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers

Your code $g = "f"; isn't really copying the function to another variable, it's just creating a string reference to the same function. The following would be more analogous to the CFML you provide:

$x = function() {
   echo __FUNCTION__;
};

$v = $x;
$v();
load more v
88%

Returns the name of the variable used to call a defined function. This function can be used to return data from CFCs by simulating getters and setters., getFunctionCalledName() → returns string ,Example of using getFunctionCalledName to create dynamic getters and setters,getFunctionCalledName

Show results of calling a function directly versus by reference

void function actualFunctionName(){
    writeOutput("actualFunctionName() was called as: #getFunctionCalledName()#<br>");
}
writeOutput("<hr><h4>Calling actualFunctionName()</h4>");
actualFunctionName();
writeOutput("<hr><h4>Calling actualFunctionName() via reference</h4>");
referenceToFunction = actualFunctionName;
referenceToFunction();
load more v
72%

PHP equivalence: onMissingMethod(),PHP equivalence: getFunctionCalledName(),Looking at PHP's OOP from a CFMLer's perspective: ...,PHP: significant oversight in the implementation o...


// Missing.cfc
component {
   public
   function onMissingMethod(name, args) {
      writeDump(arguments);
   }
}
load more v
65%

GetFunctionCalledName() ,Returns the name of variable used to call the current function, Reference Functions Tags Objects Additional Tags & Functions Unsupported Tags & Functions Deprecated Tags & Functions

yell = function(name) {
   echo(name);
   dump(var = getFunctionCalledName(), label = "Function was called as");
};
yell("yell");
say = yell; // copy function
say("say from ");
yell = say; // copy function again
yell("yell from say");
75%

cfexit can be used to abort the processing of the currently executing CFML custom tag. Execution resumes following the invocation of the custom tag in the page that called the tag. ,If you remove the comments, this code redirects you to CFDOCS home page:,This tag redirects the browser to a web resource; normally, you would use this tag to go to a CF page or an HTML file on the same server. The addToken attribute lets you send client information to the target page.,This example uses a sample custom tag that is saved in myTag.cfm in the snippets directory. You can also save ColdFusion custom tags in the CFusionMX7\CustomTags directory.

Email:

   From:

   Subject:
   Message:
   Date Posted: #DateFormat(Now()) #
load more v

Other "called-function" queries related to "Get the name a function was called as, equivalent to CFML's getFunctionCalledName()"