note 78373 deleted from language.oop5.overloading by danbrown

From: Date: Mon, 20 Jun 2011 15:29:51 +0000
Subject: note 78373 deleted from language.oop5.overloading by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180774@lists.php.net to get a copy of this message
Note Submitter: zachary dot craig at goebelmediagroup dot com ---- @egingell at sisna dot com - Use of __call makes "overloading" possible also, although somewhat clunky... i.e. <?php class overloadExample { function __call($fName, $fArgs) { if ($fName == 'sum') { if (count ($fArgs) === 1) { return $fArgs[0]; } else { $retVal = 0; foreach( $fArgs as $arg ) { $retVal += $arg; } return $retVal; } } } } /* Simple and trivial I realize, but the point is made. Now an object of class overloadExample can take */ echo $obj->sum(4); // returns 4 echo $obj->sum(4, 5); // returns 9 ?>

« previous php.notes (#180774) next »