note 117243 deleted from functions.arguments by cmb

From: Date: Sun, 10 Nov 2019 12:56:08 +0000
Subject: note 117243 deleted from functions.arguments by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213014@lists.php.net to get a copy of this message
Note Submitter: rich at richware dot net ---- How to pass a class as an argument? This is simple: <?php class TMath { private $_Total; function Sum() { $this->_Total = 0; foreach (func_get_args() as $n) { $this->_Total += $n; } } function Total() { return $this->_Total; } } $myMath = new TMath(); $myMath->Sum(1,2,3); ShowTotal($myMath); function ShowTotal($aMath) { echo $aMath->Total().'<br/>'; }

« previous php.notes (#213014) next »