Hi guys,
Is it possible to overload a method in php like in java? I mean how to make a method overloaded?
thanking youi
saumya
is method overloading possible in php?
Moderator: General Moderators
What is called "overloading" in PHP is significantly different from what overloading means in most other languages. Overloading typically means having different signatures for the same named method (or function) and having those different signature react appropriatly. This often worked off of type hints (type fatals actually
in php ) in statically typed languages. In PHP, you would have to encode all of the possible signatures and behaviors within the same function body. You have a lot of flexibility: default parameters, checking parameter types (is_numeric, is_string, is_object), checking class (is_a, instance_of, get_class), duck typing, and allowing for variable parameter lists (funct_num_args, funct_get_args).
HTH
HTH
thank you.
Yes,you are right.
this is the thing i got to know, when i read the article given by patrikG.
here overloading does something else. One has to write all the methods to deal with different type of datas and number of datas manually.WEll, no problem.I was just seeking the info. Now i know i have to write it manually, so ai will go about it calmly.Or else i would have been searching for how to write an overloaded method.
thanking you
saumya
Yes,you are right.
this is the thing i got to know, when i read the article given by patrikG.
here overloading does something else. One has to write all the methods to deal with different type of datas and number of datas manually.WEll, no problem.I was just seeking the info. Now i know i have to write it manually, so ai will go about it calmly.Or else i would have been searching for how to write an overloaded method.
thanking you
saumya