your code has a syntax error:
$this->$db_host should be $this->db_host and so on.
FWIW,
A good place to look for some sample code would be phplib.
For example, from their code, they use a local.inc to extend the basic library code, eg.
class DB_Example extends DB_Sql {
var $Host = "localhost";
var $Database = "example_database";
var $User = "example_user";
var $Password = "";
}
all that's happening here is to actually set some of the variables so that you don't have to pass them when you instantiate the object. IOW, when I type $db = new DB_Example; I am automatically connected, where if I typed $db = new DB_Sql, I would have to access some method to input host, database, etc.
Another way extending a class can be used is to change the way one of the methods works:
class Example_Challenge_Auth extends Auth {
var $classname = "Example_Challenge_Auth";
var $lifetime = 1;
var $magic = "Simsalabim"; ## Challenge seed
var $database_class = "DB_Example";
var $database_table = "auth_user";
function auth_loginform() {
global $sess;
global $challenge;
global $_PHPLIB;
$challenge = md5(uniqid($this->magic));
$sess->register("challenge");
include($_PHPLIB["libdir"] . "crloginform.ihtml");
}
function auth_validatelogin() {
global $username, $password, $challenge, $response;
... etc.
}
What this does is actually change the auth_login() method to use md5 passwords. So if I have $auth = new auth(), I am using plain text passwords, but if I have $auth = new Example_Challenge_Auth, I will be using md5 passwords.