Re: extends in php

[email protected] (Vicenc Gasco) Tue, 28 Feb 2012 13:10:00 +0100
Newsgroups php.evangelism
Message-ID <[email protected]>
--Apple-Mail=_BABC4EFC-2B82-4A72-8C52-BB57BB897718
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=iso-8859-1

The extends keyword serves to declare inheritance, from the parent class =
(the one that is extended) to a child class.
When declaring something like Dog extends Animal, the Dog class becomes =
a subclass, that obtains all the methods declared in Animal, unless you =
overwrite them in the Dog declaration. If you redeclare a method, you =
can still call the parent method by: parent::method();

You should take a look at: http://es.php.net/manual/en/language.oop5.php
--
Vicenc Gasco
[email protected]


On Feb 28, 2012, at 1:03 PM, jimmy he <[email protected]> he =
wrote:

> how does extend of php implement? it has much difference with =
c++/java, i think.is it a simple combination of functions in parent =
class and itself?


--Apple-Mail=_BABC4EFC-2B82-4A72-8C52-BB57BB897718
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=iso-8859-1

<html><head></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div =
apple-content-edited=3D"true"><span class=3D"Apple-style-span" =
style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-style: normal; font-variant: normal; font-weight: =
normal; letter-spacing: normal; line-height: normal; orphans: 2; =
text-align: -webkit-auto; text-indent: 0px; text-transform: none; =
white-space: normal; widows: 2; word-spacing: 0px; =
-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span =
class=3D"Apple-style-span" style=3D"border-collapse: separate; color: =
rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: =
normal; font-weight: normal; letter-spacing: normal; line-height: =
normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; =
text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; =
-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div =
style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space; ">The extends keyword serves to =
declare inheritance, from the parent class (the one that is extended) to =
a child class.<div>When declaring something like Dog extends Animal, the =
Dog class becomes a subclass, that obtains all the methods declared in =
Animal, unless you overwrite them in the Dog declaration. If you =
redeclare a method, you can still call the parent method by: =
parent::method();</div><div><br></div><div>You should take a look =
at:&nbsp;<a =
href=3D"http://es.php.net/manual/en/language.oop5.php">http://es.php.net/m=
anual/en/language.oop5.php</a></div><div><div =
apple-content-edited=3D"true"><span class=3D"Apple-style-span" =
style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-style: normal; font-variant: normal; font-weight: =
normal; letter-spacing: normal; line-height: normal; orphans: 2; =
text-align: -webkit-auto; text-indent: 0px; text-transform: none; =
white-space: normal; widows: 2; word-spacing: 0px; =
-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span =
class=3D"Apple-style-span" style=3D"border-collapse: separate; color: =
rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: =
normal; font-weight: normal; letter-spacing: normal; line-height: =
normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; =
text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; =
-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div =
style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space; ">--</div><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; ">Vicenc Gasco<br><a =
href=3D"mailto:[email protected]">[email protected]</a></div></span></span></d=
iv></div><br></div></span></span>
</div>
<br><div><div>On Feb 28, 2012, at 1:03 PM, jimmy he &lt;<a =
href=3D"mailto:[email protected]">[email protected]</a>&gt; =
he wrote:</div><br class=3D"Apple-interchange-newline"><blockquote =
type=3D"cite">how does extend of php implement? it has much difference =
with c++/java, i <a href=3D"http://think.is/" =
target=3D"_blank">think.is</a> it a simple combination of functions in =
parent class and itself?
</blockquote></div><br></body></html>=

--Apple-Mail=_BABC4EFC-2B82-4A72-8C52-BB57BB897718--