On 10 Dec, 14:17, Matthew <matt...@spamki ller.comwrote:
>Am I correct in thinking there is no method/function overloading of any
>kind in any version of PHP?
>>
>Thanks,
>>
>Matthew
>
Depends if any of the about 758,000 items found by putting the words
>
overloading php
>
into Google fit the bill.
I did that before posting, and got hits for class, property, method, and
an extension for overloading. When I looked in manual I found a function
called overload() which will enable method and property overloading in PHP
versions 4 >= 4.2.0.
I can't seem to find a simple answer to my question, hence my post, which
is specific to methods/functions (including constructors). I was unable to
find an example of what I would call 'method overloading' that you would
use in C++, Java, C#, etc..
EG.
function DoThis()
{
//something
}
function DoThis($var1)
{
//something
}
function DoThis($var1, $var2)
{
//something
}
the method that runs is chosen simply on the basis of the number of arguments.
On 10 Dec, 14:56, Matthew <matt...@spamki ller.comwrote:
Captain Paralytic emailed this:
>
On 10 Dec, 14:17, Matthew <matt...@spamki ller.comwrote:
Am I correct in thinking there is no method/function overloading of any
kind in any version of PHP?
>
Thanks,
>
Matthew
>
Depends if any of the about 758,000 items found by putting the words
>
overloading php
>
into Google fit the bill.
>
I did that before posting, and got hits for class, property, method, and
an extension for overloading. When I looked in manual I found a function
called overload() which will enable method and property overloading in PHP
versions 4 >= 4.2.0.
>
I can't seem to find a simple answer to my question, hence my post,
Your question was whether you were right in "thinking there is no
method/function overloading of any kind in any version of PHP"
You have now said that "I found a function called overload() which
will enable method and property overloading"
So it seems pretty obvious to me that you already had the answer to
the question you asked.
Am I correct in thinking there is no method/function overloading of any
kind in any version of PHP?
>
Thanks,
>
Matthew
>
Not in the way I think you're saying - where two methods in the same
class (or both not in any class) can have the same name but different
parameter lists . PHP hasn't gotten that far yet. Maybe in a future
release.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attgl obal.net
=============== ===
On Dec 10, 9:56 am, Matthew <matt...@spamki ller.comwrote:
Captain Paralytic emailed this:
>
On 10 Dec, 14:17, Matthew <matt...@spamki ller.comwrote:
Am I correct in thinking there is no method/function overloading of any
kind in any version of PHP?
>
Thanks,
>
Matthew
>
Depends if any of the about 758,000 items found by putting the words
>
overloading php
>
into Google fit the bill.
>
I did that before posting, and got hits for class, property, method, and
an extension for overloading. When I looked in manual I found a function
called overload() which will enable method and property overloading in PHP
versions 4 >= 4.2.0.
>
I can't seem to find a simple answer to my question, hence my post, which
is specific to methods/functions (including constructors). I was unable to
find an example of what I would call 'method overloading' that you would
use in C++, Java, C#, etc..
>
EG.
>
function DoThis()
{
//something}
>
function DoThis($var1)
{
//something}
>
function DoThis($var1, $var2)
{
//something
>
}
>
the method that runs is chosen simply on the basis of the number of arguments.
>
Thanks.
You can achieve the same thing by using default values for function
parameters:
function DoThis($var1 = 'foo', $var2 = 'bar')
If you don't provide values for those parameters it will take the
default instead.
>Am I correct in thinking there is no method/function overloading of
>any kind in any version of PHP?
>>
>Thanks,
>>
>Matthew
>>
>
Not in the way I think you're saying - where two methods in the same
class (or both not in any class) can have the same name but different
parameter lists . PHP hasn't gotten that far yet. Maybe in a future
release.
Thanks Jerry - this is what I meant and wanted to know.
Cheers.
On Dec 10, 9:56 am, Matthew <matt...@spamki ller.comwrote:
>Captain Paralytic emailed this:
>>
>>On 10 Dec, 14:17, Matthew <matt...@spamki ller.comwrote:
>>>Am I correct in thinking there is no method/function overloading of any
>>>kind in any version of PHP?
>>>Thanks,
>>>Matthew
>>Depends if any of the about 758,000 items found by putting the words
>>overloading php
>>into Google fit the bill.
>I did that before posting, and got hits for class, property, method, and
>an extension for overloading. When I looked in manual I found a function
>called overload() which will enable method and property overloading in PHP
>versions 4 >= 4.2.0.
>>
>I can't seem to find a simple answer to my question, hence my post, which
>is specific to methods/functions (including constructors). I was unable to
>find an example of what I would call 'method overloading' that you would
>use in C++, Java, C#, etc..
>>
>EG.
>>
>function DoThis()
>{
> //something}
>>
>function DoThis($var1)
>{
> //something}
>>
>function DoThis($var1, $var2)
>{
> //something
>>
>}
>>
>the method that runs is chosen simply on the basis of the number of arguments.
>>
>Thanks.
>
You can achieve the same thing by using default values for function
parameters:
>
function DoThis($var1 = 'foo', $var2 = 'bar')
>
If you don't provide values for those parameters it will take the
default instead.
It's not the same thing. But thanks for the hint.
Cheers.
On Dec 10, 11:40 am, Matthew <matt...@spamki ller.comwrote:
ZeldorBlat emailed this:
>
>
>
On Dec 10, 9:56 am, Matthew <matt...@spamki ller.comwrote:
Captain Paralytic emailed this:
>
>On 10 Dec, 14:17, Matthew <matt...@spamki ller.comwrote:
>>Am I correct in thinking there is no method/function overloading of any
>>kind in any version of PHP?
>>Thanks,
>>Matthew
>Depends if any of the about 758,000 items found by putting the words
>overloading php
>into Google fit the bill.
I did that before posting, and got hits for class, property, method, and
an extension for overloading. When I looked in manual I found a function
called overload() which will enable method and property overloading in PHP
versions 4 >= 4.2.0.
>
I can't seem to find a simple answer to my question, hence my post, which
is specific to methods/functions (including constructors). I was unable to
find an example of what I would call 'method overloading' that you would
use in C++, Java, C#, etc..
>
EG.
>
function DoThis()
{
//something}
>
function DoThis($var1)
{
//something}
>
function DoThis($var1, $var2)
{
//something
>
}
>
the method that runs is chosen simply on the basis of the number of arguments.
>
Thanks.
>
You can achieve the same thing by using default values for function
parameters:
>
function DoThis($var1 = 'foo', $var2 = 'bar')
>
If you don't provide values for those parameters it will take the
default instead.
>
It's not the same thing. But thanks for the hint.
Cheers.
I didn't say it was the same. But you can achieve the same effect.
I've seen plenty of constructs like this:
function DoThis() {
return DoThis('foo');
}
function DoThis($var1) {
return DoThis($var1, 'bar');
}
Comment