note 114963 added to language.oop5.decon
| From: | kayvin86 at live dot com | Date: | Tue, 06 May 2014 17:16:18 +0000 |
| Subject: | note 114963 added to language.oop5.decon | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199427@lists.php.net to get a copy of this message | ||
putting in more layman's term
class dad{
function __construct() {
echo get_class($this) . ' is fair and tall <br>';
}
}
//inherit and overidding parent constructor
class son extends dad{
function __construct(){
parent::__construct();
echo get_class($this) . ' is handsome <br>';
}
}
//overidding parent constructor
class daughter extends dad{
function __construct(){
echo get_class($this) . ' is tan like her mother <br>';
echo get_class($this) . ' is pretty and has nothing to do with dad <br>';
}
}
echo 'im dad: <br>';
$dad = new dad();
echo '<br>';
echo 'born a son: <br>';
$son = new son();
echo '<br>';
echo 'born a daughter: <br>';
$daughter = new daughter();
/*output
im dad:
dad is fair and tall
born a son:
son is fair and tall (notice that when parent:: is call inside son, son will be the class inside
dad's contructor)
son is handsome
born a daughter:
daughter is tan like her mother
daughter is pretty and has nothing to do with dad
*/
----
Server IP: 72.52.91.14
Probable Submitter: 175.144.200.30
----
Manual Page -- http://php.net/manual/en/language.oop5.decon.php
Edit -- https://master.php.net/note/edit/114963
Del: integrated -- https://master.php.net/note/delete/114963/integrated
Del: useless -- https://master.php.net/note/delete/114963/useless
Del: bad code -- https://master.php.net/note/delete/114963/bad+code
Del: spam -- https://master.php.net/note/delete/114963/spam
Del: non-english -- https://master.php.net/note/delete/114963/non-english
Del: in docs -- https://master.php.net/note/delete/114963/in+docs
Del: other reasons-- https://master.php.net/note/delete/114963
Reject -- https://master.php.net/note/reject/114963
Search -- https://master.php.net/manage/user-notes.php