Re: OOP: __construct() and "extend"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey,

Constructors behave the same way as regular methods with inheritance,
you have to manually call the parent constructor, ie:
parent::__construct().

Regards,

Jonathan

On Tue, Dec 22, 2009 at 7:45 PM, APseudoUtopia <apseudoutopia@xxxxxxxxx> wrote:
> Hey list,
>
> I'm writing my own class which extends upon the Memcached class
> (php.net/memcached).
>
> I'm a bit confused as to how the constructor works when extending a class.
>
> class caching extends Memcached {
> function __construct() {
> echo "Caching Class Construct!";
> }
> }
>
> For something like the above code, is the Memcached constructor
> called? Or do I have to explicitly call it via parent::__construct()
> within the caching class?
>
> Thanks.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux