How to check if a function is public or protected in PHP
<p>I am building an API where the user requests a 'command', which is passed into a class. Assuming the command matches a PUBLIC function, it will execute successfully.
If the command matches a PROTECTED function, it needs to throw an error.</p>

<p>The idea is that functions can be disabled by changing them from PUBLIC to PROTECTED, rather than renaming them or removing them.</p>

<p>I currently do this, but it doesn't matter if the command is public or protected.</p>

<pre><code>&lt;?php
/**
 * Look for Command method
 */
$sMethod = "{$sCommand}Command";
if (method_exists($this, $sMethod))
{
    /**
     * Run the command
     */
    return $this-&gt;$sMethod($aParameters);
}
</code></pre>
