[PHP] OO function overloading?

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Re: [PHP] OO function overloading?

    Hi,

    This statement isn't entirely correct, overloading is possible with the
    overload extension.

    [url]http://www.php.net/overload[/url]

    Regards,
    Greg
    --
    phpDocumentor
    [url]http://www.phpdoc.org[/url]

    Curt Zirzow wrote:
    > * Thus wrote Jean-Christian IMbeault (jc@mega-bucks.co.jp):
    >
    >>Is it possible to overload a function is a class. I would like to have
    >>the same function defined differently depending on the number of
    >>arguments passed in. For example:
    >
    >
    > overloading isn't possible in php4.
    >
    > Curt
    Greg Beaver Guest

  2. Similar Questions and Discussions

    1. #40441 [NEW]: mbstring function overloading turns on randomly
      From: dmitry at rsl dot ru Operating system: linux PHP version: 5.2.1 PHP Bug Type: mbstring related Bug description: ...
    2. #39361 [NEW]: mbstring function overloading - local value ignored
      From: christoph at ziegenberg dot de Operating system: Win XP SP 2 PHP version: 5.2.0 PHP Bug Type: mbstring related Bug...
    3. #39361 [Opn]: mbstring function overloading - done although not activated
      ID: 39361 User updated by: christoph at ziegenberg dot de -Summary: mbstring function overloading - local value ignored...
    4. newbie question: function overloading
      I need to define a method that performs differently when operated on objects of different type (overloading). Currently I use various if's to check...
    5. Overloading ()
      Hi, I was reading the comp.lang.functional group, and happened across a little discussion of Ruby vs. Python on there. One thing the Python guy...
  3. #2

    Default Re: [PHP] OO function overloading?

    Greg Beaver wrote:
    > This statement isn't entirely correct, overloading is possible with the
    > overload extension.
    True. Nice work. But still a hack in my mind :) (though a *very* clean
    hack).

    Jean-Christian Imbeault

    Jean-Christian Imbeault Guest

  4. #3

    Default RE: [PHP] OO function overloading?

    Or, if you'd rather not use an experimental extension, there's this hack
    (learned from [url]http://www.phpbuilder.com/columns/luis20000420.php3):[/url]

    class MyClass{

    function MyClass(){
    $name = 'MyClass' . func_num_args();
    $this->$name();
    }

    function MyClass1($x){
    }

    function MyClass2($x,$y){
    }

    function MyClass3($x,$y,$z){
    }

    //etc.
    }

    Andy
    > -----Original Message-----
    > From: Greg Beaver [mailto:greg@chiaraquartet.net]
    > Sent: Wednesday, August 06, 2003 1:09 AM
    > To: Jean-Christian Imbeault
    > Cc: [email]php-general@lists.php.net[/email]
    > Subject: Re: [PHP] OO function overloading?
    >
    > Indeed it is a hack, but not for PHP 5, the extension has become part
    of
    > the core, and does not require that odd little "overload()" call :)
    >
    > Greg
    >
    > Jean-Christian Imbeault wrote:
    >
    > > Greg Beaver wrote:
    > >
    > >
    > >>This statement isn't entirely correct, overloading is possible with
    the
    > >>overload extension.
    > >
    > >
    > > True. Nice work. But still a hack in my mind :) (though a *very*
    clean
    > > hack).
    > >
    > > Jean-Christian Imbeault
    > >
    >
    >
    > --
    > PHP General Mailing List (http://www.php.net/)
    > To unsubscribe, visit: http://www.php.net/unsub.php


    Andy Crain Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139