I know it is possible to overload PHP functions as I have seen this done with many of the prebuilt functions. My question is how do you declare an overloaded function? Everytime I try doing this I always get some error about missing arguments (even if there exsist a function with the same number of arguments)
paradox814
1
Posting Whiz
Recommended Answers
Jump to PostFound this quote:
PHP does not support function overloading, nor is it possible to undefine or redefine previously-declared functions.[
and this code:
Method overloading is however permitted.
<?php class A { function A() { } function ech() { $a = func_get_args(); for( $t=0;$t<count($a); $t++ ) …
Jump to PostI know it is possible to overload PHP functions as I have seen this done with many of the prebuilt functions. My question is how do you declare an overloaded function? Everytime I try doing this I always get some error about missing arguments (even if there exsist a function …
Jump to PostPHP isn't strongly typed, making the function overload, as we are used, kinda senseless. In most languages that allow function overloading, you have to differentiate the several overloads by the parameters types.
So there are some workarounds to do it in PHP. We can check the parameters (after setting default …
Jump to PostPHP does not support method overloading.PHP support only method over riding
All 14 Replies
DanceInstructor
19
Posting Whiz
harrisonad
0
Newbie Poster
imran.gnit
0
Newbie Poster
imran.gnit
0
Newbie Poster
imran.gnit
0
Newbie Poster
cburke
-1
Newbie Poster
somedude3488
commented:
Why post on 4+ year old thread? Pointless.
-1
kvprajapati
1,826
Posting Genius
Team Colleague
Petrini
0
Newbie Poster
pssubash
0
Light Poster
pssubash
0
Light Poster
mschroeder
251
Bestower of Knowledge
Team Colleague
Petrini
0
Newbie Poster
arionyx
0
Newbie Poster
NuMessiah
0
Newbie Poster
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.