Hi follks;
Does PHP4 supports overloading and overriding like Java?
Thanks in advance!
Billy
Yea, it does kinda. You can override any function but it is an implicit override...any function that is overridden in a child is never called in the parent, so if you have funct() on both, only child will be called.
parent.funct() will never be called and there is no way to flag a function as extends instead of overrides
What about overloading? For example, there are 2 functions:
function_a (String str, boolean b) { .... }
function_a (String a) { ...... }
One of the function above will be called depends on the no. of args that are passed in. Will PHP4 supports something like this?
Thanks!
Not true overloading, but
function varyingparms() {
}
then call a function, I forget the name (check the docs), similar to array = get_function_parms();
then switch based on types etc.
you can find this sort of workarounds in an article by Luis Argerich called "OO Programming in PHP The way to large PHP projects" ... i found it quit usefull ...
cya Rob
hi, where can i get this article by Luis Argerich, Rob ?
of course on this page :-)))
here we go:
http://www.phpbuilder.com/columns/luis20000420.php3