note 78373 added to language.oop5.overloading

From: Date: Tue, 09 Oct 2007 05:13:54 +0000
Subject: note 78373 added to language.oop5.overloading
Groups: php.notes 
Request: Send a blank email to php-notes+get-131243@lists.php.net to get a copy of this message
@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 ?> ---- Server IP: 208.69.120.35 Probable Submitter: 72.145.80.162 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.overloading.php Edit -- https://master.php.net/note/edit/78373 Del: integrated -- https://master.php.net/note/delete/78373/integrated Del: useless -- https://master.php.net/note/delete/78373/useless Del: bad code -- https://master.php.net/note/delete/78373/bad+code Del: spam -- https://master.php.net/note/delete/78373/spam Del: non-english -- https://master.php.net/note/delete/78373/non-english Del: in docs -- https://master.php.net/note/delete/78373/in+docs Del: other reasons-- https://master.php.net/note/delete/78373 Reject -- https://master.php.net/note/reject/78373 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131243) next »