For Business
Login
Home
Assessments
Mytat Certificates
Community
Courses
Premium Courses
jobs
Practice
Upskilling
Projects
Help
Run »
balance = $initialBalance; } public function deposit($amount) { $this->balance += $amount; } public function withdraw($amount) { if ($amount <= $this->balance) { $this->balance -= $amount; } else { echo "Insufficient funds"; } } public function getBalance() { return $this->balance; } } // Create an object of the BankAccount class $account = new BankAccount(1000); // Deposit and withdraw money $account->deposit(500); $account->withdraw(200); // Get the current balance echo "Current balance: $" . $account->getBalance(); // Output: Current balance: $1300 ?>