how to ovaerload the method........
please explain with example

Recommended Answers

All 4 Replies

There is no method overloading in php. Any solution to this, and there are many, will be a hack.

check this..

Don't mistake this for real method overloading, this is actually a misuse of the term "method overloading". __call and __callStatic simply give you a means of calling methods that aren't declared in the class. You would still need a way to determine how many and what type of parameters are being sent so that you can use that information to determine the correct method to call, which actually has more to do with func_get_args, func_get_arg and func_num_args than __call and __callStatic.

I actually wouldn't use __call and __callStatic to overload a method but instead define the method in question and use func_get_args, func_get_arg and func_num_args to apply the logic required to overload it.

OK R0bb0b....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.