note 42529 added to ref.overload

From: Date: Thu, 20 May 2004 07:18:58 +0000
Subject: note 42529 added to ref.overload
Groups: php.notes 
Request: Send a blank email to php-notes+get-69862@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/ref.overload.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42529 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42529&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42529&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69862) next »