Forum Moderators: coopster
In the first one, someone mentioned something about variable functions and their usefulness. I didn't feel like sorting through all the other posts to see what people had posted, but I have a really good use for them. A dynamic database class. Say your database class may need to connect to either a MSSQL server or a MySQL server. And, it's possible the server might be running PHP 5, so then you may need to utilize the MySQLi functions, instead. Simple enough, most of those three classes of functions are identical, with a few exceptions, of course. But, here's the example:
class database {
// yada yada
public $type = 'mysqli'; // default type
// more stuff
// example function
public query($sql, $link) {
$query = $this->type.'_query';
return $query($sql, $link);
}
}
Note that this is just an example. I have a single class that I use reguardless of the server type :)