From:             php_net at foq dot nl
Operating system: debian etch
PHP version:      5.2.9
PHP Bug Type:     Class/Object related
Bug description:  child constructor not executed

Description:
------------
I am using a base class and a lot of classes which extend that base class.
When i add class variables in the base class i can use those in the
extending class. All goed well. But when i set variables from the base
class constructor then the extended class does not get these new values. I
tested, and the base class constructor is not executed.

Reproduce code:
---------------
class base {
    var $mysql_link = null;
    var $test = "hello";

    function base() {
      $this->test = "helloolleh";
      $this->mysql_link = mysql_connect("host", "user", "pass");
      if(!$this->mysql_link)
        exit("mysql connection failed.");
    }
}

class photo extends base {
      photo() {
        print "photo constructor is working!\n";
        print "But the base class not: '".$this->test."'\n";
        mysql_query("Select foo from bar", $this->mysql_link) or
die(mysql_error());
      }
}

$p = new photo();

Expected result:
----------------
photo constructor is working!
helloolleh
Error in query

Actual result:
--------------
 // nothing
hello
mysql: not a valid resource identifier

-- 
Edit bug report at http://bugs.php.net/?id=48354&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=48354&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=48354&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=48354&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=48354&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=48354&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=48354&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=48354&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=48354&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=48354&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=48354&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=48354&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=48354&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=48354&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=48354&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48354&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48354&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=48354&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=48354&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=48354&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=48354&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=48354&r=mysqlcfg

Reply via email to