Exemple #1
0
            echo "Error: insufficient funds!<br>\n";
        }
    }
    function print_log()
    {
        $attr = array("date", "operation", "amount", "old_balance", "new_balance");
        echo "<table>";
        for ($i = 0; $i < count($this->_log); $i++) {
            echo "<tr>";
            for ($j = 0; $j < count($attr); $j++) {
                echo "<td>" . $this->_log[$i][$attr[$j]] . "</td>";
            }
            echo "</tr>";
        }
        echo "</table>";
    }
}
// test
$ba = new BankAccount("my name", 1000);
echo "Balance: " . $ba->get_balance() . "<br>\n";
$ba->deposit(200);
$ba->deposit(300);
echo "Balance: " . $ba->get_balance() . "<br>\n";
$ba->withdraw(500);
echo "Balance: " . $ba->get_balance() . "<br>\n";
$ba->withdraw(2000);
$ba->print_log();
?>
</body>
</html>