note 118033 added to keyword.class
| From: | ender911t at gmail dot com | Date: | Mon, 21 Sep 2015 21:20:00 +0000 |
| Subject: | note 118033 added to keyword.class | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203832@lists.php.net to get a copy of this message | ||
Overrides in child are called when calling a function from the parent
<?PHP
class Par
{
var $test;
function __construct($in)
{
$this->test = $in;
}
function getTest()
{
return $this->test;
}
function runTest()
{
return $this->getTest();
}
}
class Chi extends Par
{
var $i;
function __construct($in)
{
$this->i = $in;
parent::__construct($in."X");
}
function getTest()
{
return $this->i;
}
function runParentTestA()
{
return parent::runTest();
}
function runParentTestB()
{
return parent::getTest();
}
}
$p = new Par("par");
$c = new Chi("chi");
echo $p->runTest()." == par";
echo $c->runTest()." == chi";
echo $c->runParentTestA()." == chi";
echo $c->runParentTestB()." == chiX";
?>
----
Server IP: 72.52.91.14
Probable Submitter: 204.209.209.138
----
Manual Page -- http://php.net/manual/en/keyword.class.php
Edit -- https://master.php.net/note/edit/118033
Del: integrated -- https://master.php.net/note/delete/118033/integrated
Del: useless -- https://master.php.net/note/delete/118033/useless
Del: bad code -- https://master.php.net/note/delete/118033/bad+code
Del: spam -- https://master.php.net/note/delete/118033/spam
Del: non-english -- https://master.php.net/note/delete/118033/non-english
Del: in docs -- https://master.php.net/note/delete/118033/in+docs
Del: other reasons-- https://master.php.net/note/delete/118033
Reject -- https://master.php.net/note/reject/118033
Search -- https://master.php.net/manage/user-notes.php