Method overriding is one of the core principles of any Object Oriented
(OO) language. By having second_class extend first_class you get all the
functionality of first_class, but generally you extend a class because
you want to inherit all of the functionality with a few differences. For
this reason method overriding is important to get the different
functionality but maintain the developer interface. So yes the behaviour
you are asking about is correct. Generally speaking I can't see a
problem occuring between Smarty and ADODB, since you are extending
these, and you can currently only extend one or the other. So it follows
that multiple definitions cannot occur unless you specifically attempt
to multiply define the same method.

HTH and HIU (Hope I Understood :)

Cheers,
Rob.


On Sun, 2003-09-21 at 12:41, Gerard Samuel wrote:
> Just double checking with the php crowd.
> Code example:
> -------------
> <?php
> 
> $bar = new second_class;
> echo $bar->foo() . '<br />';
> var_dump(get_class_methods('second_class'));
> 
> class first_class
> {
>     function foo()
>     {
>         echo 'foo from class first_class';
>     }
> }
> 
> class second_class extends first_class
> {
>     function foo()
>     {
>         echo 'foo from class second_class';
>     }
> }
> 
> ?>
> -----------
> My goal (if feasable).  To be able to house multiple classes under one 
> class, and to not have copied references of one class in
> another.
> For example, housing ADODB, Smarty, and other misc classes under one 
> class/object,
> and not having a copied reference to ADODB in other "child" classes that 
> need access to a database.
> Now to my code snippet above.
> What Im testing is to see if class methods behave like regular 
> functions, where
> it cannot be defined more than once.
> Trying to define a function more than once produces an error, but it 
> seems that redefining a class method overwrites the previous class 
> method of the same name.
> So if I were to work towards my goal, there is a possiblity that class 
> methods can overwrite themselves.
> So (theoritically) if Smarty and ADODB have the same class method names, 
> problems would arise.
> 
> So Im looking to see if this is "normal" class behaviour.
> If so, then I shouldn't even try to work towards my goal, as its not 
> prudent.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

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

Reply via email to