note 42529 rejected from ref.overload by betz
| From: | betz@php.net | Date: | Thu, 20 May 2004 08:31:53 +0000 |
| Subject: | note 42529 rejected from ref.overload by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-69864@lists.php.net to get a copy of this message | ||
Note Submitter: kirkcerny501@hotmail.com
----
I attemted to get this to work for hours and was unsuccessful.
I even cut and pasted the code, and still could not get it to work.
<?php
class Name
{
var $FirstName;
var $LastName;
function Name($first, $last)
{
$numargs = func_num_args();
if($numargs >= 2)
{
$this->FirstName = $first;
$this->LastName = $last;
}
else
{
$names = explode($first);
$this->FirstName = $names[0];
$this->LastName = $names[1];
}
}
}
$myName = new Name ('joe');
echo ($myname->FirstName." ".$myName->lastName."kirk");
?>
This gives an error of
Warning: Missing argument 2 for name() in /var/www/html/admin/testclass.php on line 8
The purpose of overloading is to be able to change the number of arguments a function is passed.
Please help.