note 62558 added to keyword.extends
| From: | Edward_nl at osu1 dot php dot net | Date: | Fri, 03 Mar 2006 10:54:48 +0000 |
| Subject: | note 62558 added to keyword.extends | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104764@lists.php.net to get a copy of this message | ||
If you are using a child-class. Remember to call the constructor of the parent class aswell before
you start using it. Otherwise you might get different results then you expected. It is stated in
this document, but I got confused by the given example. So, here is my example:
<?php
error_reporting(E_ALL);
class test {
var $var;
function test() {
$this->var = 3;
}
}
class testing extends test {
function testing() {
parent::test();
}
function My_test() {
return $this->var;
}
}
$p = new testing();
echo $p->My_test();
// Returns 3
----
Server IP: 194.109.193.119
Probable Submitter: 80.100.102.122
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/keyword.extends.php
Edit -- http://master.php.net/note/edit/62558
Del: integrated -- http://master.php.net/note/delete/62558/integrated
Del: useless -- http://master.php.net/note/delete/62558/useless
Del: bad code -- http://master.php.net/note/delete/62558/bad+code
Del: spam -- http://master.php.net/note/delete/62558/spam
Del: non-english -- http://master.php.net/note/delete/62558/non-english
Del: in docs -- http://master.php.net/note/delete/62558/in+docs
Del: other reasons-- http://master.php.net/note/delete/62558
Reject -- http://master.php.net/note/reject/62558
Search -- http://master.php.net/manage/user-notes.php