|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-01-30 20:17 UTC] lyric@php.net
[2001-01-30 20:18 UTC] lyric@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 03:00:01 2025 UTC |
The following class definition lists three vars, yet they are all treated as one, as the call to report() shows. I'd love to be able to define more vars in a class. <? class bankaccount { var $balance; var $transactions; var $history; function bankaccount () { $this->$balance = 0.00; $this->$transactions = 0; $this->$history[$transactions] = $this->$balance; } function report () { echo $this->$balance . "<br>"; echo $this->$transactions . "<br>"; echo $this->$history[$transactions] . "<br>"; } function credit ($amount) { $amount = abs($amount); $this->$balance += $amount; } function debit ($amount) { $amount = abs($amount); $this->$balance -= $amount; } } $USDaccount = new bankaccount; $USDaccount->credit(10000); $USDaccount->debit(1000); $USDaccount->debit(.78); $USDaccount->report(); ?> the result is: 8999.22 8999.22 8999.22 Why?