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

Active3 hr before
Viewed126 times

5 Answers


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;
load more v

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>");
writeOutput("<hr><h4>Calling actualFunctionName() via reference</h4>");
referenceToFunction = actualFunctionName;
load more v

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 {
   function onMissingMethod(name, args) {
load more v

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) {
   dump(var = getFunctionCalledName(), label = "Function was called as");
say = yell; // copy function
say("say from ");
yell = say; // copy function again
yell("yell from say");

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.



   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()"