-1

This isn't really important but the question is more one of curiosity.

Is it possible to alias a function or define two names for it.

I know this works:

function real($p1=array(), $p2=null, $p3='default'){
  return 'something';
}

function aliasForReal($p1=array(), $p2=null, $p3='default'){
  return real($p1, $p2, $p3);
}

Is there a less verbose way to alias another function?

something like

function (real||aliasForReal)(...){

or

function aliasForReal extends real;

There are a couple of places I need to do this and the working method above just feels a bit dirty to me.

For instance:

using names like (begin and start) interchangeably for one function and (end and stop) for another.

Dieter Gribnitz
  • 5,062
  • 2
  • 41
  • 38

2 Answers2

-1
function real($p1=array(), $p2=null, $p3='default'){
  return 'something';
}

$real1 = 'real';
$real2 = 'real';
// etc

You can call $real1(...)

Didar_Uranov
  • 1,230
  • 11
  • 26
-1
function real(){
    return "real";
}

function realAlias(){
    return "realAlias";
}

$p = "real";
print $p();

$p = "realAlias";
print $p();

does it help?

qwertmax
  • 3,120
  • 2
  • 29
  • 42