note 46980 added to language.oop5.decon
| From: | ravindra at gatewaytechnolabs dot com | Date: | Fri, 29 Oct 2004 09:04:47 +0000 |
| Subject: | note 46980 added to language.oop5.decon | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-79305@lists.php.net to get a copy of this message | ||
Different behaviour as compare to java and C# For Constructor.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
<?php
class staticex
{
function __construct()
{
print "In BaseClass constructor<BR>";
print "test";
}
}
class subex extends staticex
{
function __construct()
{
print "sub class constructor";
}
}
$s1=new subex();
?>
Output in above program is :sub class constructor
If Subclass has a constructor then super class constructor is not called.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
<?php
class staticex
{
function __construct()
{
print "In BaseClass constructor";
}
}
class subex extends staticex
{
}
?>
-------------------------------------------------------
------------------------------------------------------
Output in above program is :In BaseClass constructor
If Subclass does not have a constructor then super class constructor is called otherwise not.
----
Manual Page -- http://www.php.net/manual/en/language.oop5.decon.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46980
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46980&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46980&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46980&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46980&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46980&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46980&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46980&report=yes
Search -- http://master.php.net/manage/user-notes.php