note 18948 deleted from functions by jimw
| From: | jimw@php.net | Date: | Mon, 11 Feb 2002 21:08:05 +0000 |
| Subject: | note 18948 deleted from functions by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-26487@lists.php.net to get a copy of this message | ||
Some people complaint about PHP's lack of function overloading (as PHP has polymorphic
variables, overloading is not possible)
However, a limited form of overloading can be achieved:
function my_overloaded_function ($var1,$var2)
{
if (is_integer($var1))
{
//Code for the integer version
}
if (is_string($var1))
{
//Code for the string version
}
}
(Instead of declaring "function my_function(int $var1)" and "function
my_function(string $var2)", which is impossible)