#48354 [Opn]: child constructor not executed

From: Date: Thu, 21 May 2009 12:57:50 +0000
Subject: #48354 [Opn]: child constructor not executed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-137604@lists.php.net to get a copy of this message
ID: 48354 User updated by: php_net at foq dot nl Reported By: php_net at foq dot nl Status: Open Bug Type: Class/Object related Operating System: debian etch PHP Version: 5.2.9 New Comment: photo() { has to be function photo() { I wrote this code as example by hand without testing because my code library is very huge. So that is not the main problem. The PHP code executes without any syntax errors. Previous Comments: ------------------------------------------------------------------------ [2009-05-21 12:54:24] php_net at foq dot nl 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 this bug report at http://bugs.php.net/?id=48354&edit=1

« previous php.bugs (#137604) next »