# a very boring question about objects, and what's expected of them

- Thread: https://externals.io/message/10357
- Original archive: https://news-web.php.net/php.internals/10357
- Started by Steph on 2004-06-09T23:05:31+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #10357 — Steph — 2004-06-09T23:05:31+00:00

URL: https://externals.io/message/10357#10357

Good people, consider this, and tell me what's right and what's wrong:

<?php
/* mainstream PHP behaviour */
class blah {
    private $name;

    function __construct($param1, $param2) {
        $this->name = $param2."\n";
        print($this->name);
    }
}

class sonOfBlah extends blah {

    function __construct($param) { // overwriting the constructor is allowed
        $this->name = $param."\n";
        print($this->name);        // property read/write is enabled
    }
}

/* ext/mysqli behaviour */
class DB extends mysqli {

    function __construct() {
        /* Need to call parent constructor to even overwrite $host in the
constructor. If
        there is a constructor, need to call parent constructor to provide
property access
        (internal or external) */
        parent::__construct('localhost', 'root', '');
        print($this->thread_id)."\n";
    }
}

class secondDB extends mysqli {
    /* if there is no constructor, all seems well with direct inheritance
(only) */
}

new blah('blah - first param', 'blah - second param');
new sonOfBlah('sonOfBlah - first and only param');
$db = new DB();
$db2 = new secondDB('localhost', 'root', '');
print($db2->thread_id);
?>

Who's right, who's wrong, where are the weaknesses? - Discuss..

- Steph
