コード例 #1
1
{
    private $acctType;
    public function __construct($accountName = "", $accountNumber, $mobileNumber, $accountType = "")
    {
        $this->acctType = $accountType;
        //parent::__construct($accountName, $accountNumber, $mobileNumber); // explicit calling
    }
    public function getAccountNumber()
    {
        //parent::getAccountNumber();
        echo " this from savings account";
    }
}
//print_r(new SavingsAccount);
//echo Account::showMe();
$mizan = new SavingsAccount("mizan", "123456", "0000001", "savings");
echo $mizan->getAccountNumber();
print_r($mizan);
$mizan->accountName = "test";
echo $mizan->getPrivateName();
$mizan->accountType = "checking";
$savings = new Account("Mizan Rahman", 123, 123456);
//$savings->accountName = "Mizanur Rahman";
//$savings->accountNumber = "123";
//$savings->accountInitialDeposit = 100000;
//$savings->accountType = "DPS";
echo $savings::INTEREST_RATE;
echo $savings->getAccountName() . "<br />";
echo $savings->accountInitialDeposit . " is my deposit<br />";
$checking = new Account();
$checking->accountName = "tech masters";
コード例 #2
0
        $this->type = $type_input;
    }
    public function DisplayBalance()
    {
        return 'Balance: ' . $this->balance . '<br/>';
    }
    public function Withdraw($amount)
    {
        if ($this->balance < $amount) {
            echo 'Not enough money.<br/>';
        } else {
            $this->balance = $this->balance - $amount;
        }
    }
    public function Deposit($amount)
    {
        $this->balance = $this->balance + $amount;
    }
}
class SavingsAccount extends BankAccount
{
}
$alex = new BankAccount();
$alex->SetType('18-25 Current');
$alex->Deposit(100);
$alex->Withdraw(10);
$alex_savings = new SavingsAccount();
$alex_savings->SetType('Super Saver');
$alex_savings->Deposit(3000);
echo $alex->type . ' has ' . $alex->DisplayBalance() . '<br/>';
echo $alex_savings->type . ' has ' . $alex_savings->DisplayBalance();