Overloaded functions and function pointers in PHP?



Hi all,

Since PHP is a (weakly) typed language, is it possible to overload functions
based on the type of their argument?

Also, are there function pointers in PHP?


Here's why I'm asking. Consider these two function:


function foo( $arg ) { echo "foo $arg foo\n"; }

function bar() { echo "barfoo"; }


I'd like to be able to do this:

foo('hello');
foo(&bar());

to produce this:

foo hello foo
foo barfoo foo

Is this at all possible (and convenient!) with PHP?

Thanks!
Pete
.



Relevant Pages

  • Re: Things we remember...
    ... also doesn't need that sort of thing, as it is a typed language. ... Perl uses '$' to indicate that the result of a dereference is ... I have no idea what PHP ... Python doesn't use that sort of syntax. ...
    (rec.arts.sf.written)
  • Re: Overloaded functions and function pointers in PHP?
    ... > Since PHP is a typed language, is it possible to overload functions ... are there function pointers in PHP? ... If you do $func() ...
    (comp.lang.php)
  • Re: Things we remember...
    ... Somebody at IBM, probably. ... also doesn't need that sort of thing, as it is a typed language. ... other languages, Perl and PHP for instance, do not type their variables ...
    (rec.arts.sf.written)
  • Re: Things we remember...
    ... also doesn't need that sort of thing, as it is a typed language. ... Some other languages, Perl and PHP for instance, do not type their ... gcc does allow $ in identifiers in their C dialect. ... The basic character set is just the one that compilers are required to ...
    (rec.arts.sf.written)
  • Re: Why no type hints for built-in types?
    ... >> already overload functions. ... PHP needs native support for things like multibyte strings ... variable functions and variables, not at least useful for web programming, ... This allows you to avoid clumsy switch-case structures for selecting ...
    (comp.lang.php)