Is there a more elegant way to pass a function to another function in PhP?
<p>It can be done by passing the function name in a string <a href="https://stackoverflow.com/questions/627775/php-pass-function-as-param-then-call-the-function">PHP pass function as param then call the function?</a></p>

<p>Well that is very crude.</p>

<p>No type checking</p>

<p>If I refactor the function name the string containing the variable need to be fixed too manually. If we have a typo it won't be checked on compile time.</p>

<p>It's not like in vb.net where we have addressOf operator.</p>

<p>Is this really the only way to do this in PhP?</p>

<p>I mean the lamda function seems more sane. At least the variable we pass is really a functio6 and not a string.</p>

<p>Am I wrong here?</p>

<p>Is the right way to do this is to use lambda?</p>

<p>Or is there any other way?</p>

<p>I can use closures like this</p>

<pre><code>function getSelectedElements($textFile)
{

    $standardfuncline2= function (&amp;$arout,$line)
    {
        standardfuncline1 ($arout,$line);
    };
    $result = getSelectedElementsCustomFunc ($textFile,$standardfuncline2);
    return $result;
}
</code></pre>

<p>instead of </p>

<pre><code>$result = getSelectedElementsCustomFunc ($textFile,"standardfuncline1");
</code></pre>

<p>That seems to be more proven with all type checking and stuffs. However, kind of too long isn't it?</p>