Object references The right way
<?php
    class bank_account {
        var $amount;
        function bank_account($cash) {
            $this->amount = $cash;
        }
    }
    
    function deposit($account, $cash) {
        $account->amount += $cash;
    }

    function withdraw(&$account, $cash) {
        $account->amount -= $withdraw;
    }

    $wallet = new bank_account(100);
    deposit($wallet, 50);
    withdraw($wallet, 120);

    echo "The account balance is: {$this->amount}";

?>
Output
The account balance is: -20
Since deposit() wasn't pass-by-reference, the extra deposit was made to a copy of the bank account, which was then destroied when the method returned.