RE: [PHP-DEV] More OOP

From: Date: Thu, 18 Jan 2001 13:27:42 +0000
Subject: RE: [PHP-DEV] More OOP
Groups: php.dev 
Request: Send a blank email to php-dev+get-44467@lists.php.net to get a copy of this message
> -----Original Message----- > From: Thomas Watson [mailto:w@tson.dk] > Sent: Thursday, January 18, 2001 12:35 > To: php-dev@lists.php.net > Subject: [PHP-DEV] More OOP > > 1: If you are overriding an existing method in a class, it is then not > possible to call the original method. Its a very basic thing > in OOP and > should be possible. This is allowed in other languages such as C++ and > Java. In Java this is done by using the super var. (In java > they also have > the "this" var. The "super" var. is identical to "this" > whereas it just > calls the overridden method). Sounds a good idea. $super though is identical to $this in plain value but has a different type. For $super you mean $this but treated as if it were a parent class. Maybe this will be introduced soon. > 2: It would also be great if PHP supported methods with the > same name but > with different arguments. I'm not sure if this is possible in > a language > such as PHP, because that you don't have to assign a type > (int, char) to a > variable (like you do in Java and C/C++ and most other > compiled languages). As you indicate it will be difficult to do automatically, however you can do as perl does and just analyse the arguments yourself and then call a different internal implementation. function foo($foo1,$foo2=FALSE) { if ($foo1 == "oik") return $this->_foo_1($foo1,$foo2); else return $this->_foo_2($foo1,$foo2,"bink"); } You can also make use of func_get_args when writing your own dispatcher (http://www.php.net/manual/en/function.func-get-args.php) This would me more clear than anything you could hope to get in a type-free language. > > If you like me to explain my questions more in depth then just reply. > > /watson > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.dev (#44467) next »