|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-08-21 11:58 UTC] d dot khan at ventigo dot com
Description:
------------
Hello,
maybe this is bogus but I found a situation where the OOP engine doesn't behave as - at least I - would expect.
I tried to extend the PDO extension and my local construct method isn't called.
The engine always calls the parent construct method.
Greetings
Daniel Khan
Reproduce code:
---------------
Class rltxPDO extends PDO {
function __construct() {
echo 'Called in child';
}
public static function instance() {
static $instance;
if (!$instance) {
$instance = new rltxPDO();
}
return $instance;
}
}
Expected result:
----------------
Output: Called in child
Actual result:
--------------
Warning: PDO::__construct() expects at least 1 parameter, 0 given
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 09:00:02 2025 UTC |
This code: <? class test extends stdClass { function __construct() { echo 'Called in child'; } } $test = new test; ?> works fine and outputs 'Called in child' for me. Please, check it one more time and/or try newer snapshot.You example works - mine doesn't. It seems to be an oddity with extensions... Example code: <?php class test extends stdClass { function __construct() { echo 'Called in child'; } } $test = new test; Class rltxPDO extends PDO { function __construct() { echo 'Called in child 2'; } } $test2 = new rltxPDO; ?> Output: Called in child Warning: PDO::__construct() expects at least 1 parameter, 0 given in /home/shares/development/khan/wandern/html/test.php on line 19