PHP - Can I pass a function name as a function argument?
<p>I have two classes that I use to access two different tables in my db. They both have a similar constructor that looks like that:</p>

<pre><code>function __construct($db) {
    $this-&gt;db = $db;
    $userDAO = DAO_DBrecord::createUserDAO($this-&gt;db);
    $this-&gt;userDAO = $userDAO;
}
</code></pre>

<p>The other class has the same constructor except that it uses <code>createOtherTableDAO($this-&gt;db)</code>.</p>

<p>I am planning on having a couple other such classes, and it would be convenient if I could have them all inherit the same constructor, and pass <code>createAppropriateTableDAO</code> as an argument.</p>

<p>To clarify, in the first case above, <code>createUserDAO($this-&gt;db)</code> is a static function that calls a constructor in my DAO class.  The function in the DAO looks as follows:</p>

<pre><code>public static function createUserDAO($db) {
    return new DAO_DBrecord($db, 'users');
}
</code></pre>

<p>I use this method to make sure the <code>user</code> model can only call a DAO on the <code>users</code> table.</p>

<p>I'm somewhat of a beginner, and I don't think I have ever seen anything like what I want.</p>
