Skip to content

Instantly share code, notes, and snippets.

@cesarkohl
Last active August 8, 2019 15:11
Show Gist options
  • Select an option

  • Save cesarkohl/d22f8cef512e2461348a781bedf9c773 to your computer and use it in GitHub Desktop.

Select an option

Save cesarkohl/d22f8cef512e2461348a781bedf9c773 to your computer and use it in GitHub Desktop.
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
class BankAccount {
private $agency;
private $account;
private $balance;
public function __construct($agency, $account)
{
$this->agency = $agency;
$this->account = $account;
}
public function __destruct()
{
echo 'Destructed';
}
public function getBalance()
{
if ($this->agency == 1 && $this->account = 100)
$this->balance = 100;
return $this->balance;
}
}
$myAccount = new BankAccount(1, 100);
echo $myAccount->getBalance(); // return 100
unset($myAccount); // echo 'Destructed'
/////////////////////////////////////////////////////////
$array = [0, 1, 2];
print_r($array); // return Array ( [0] => 0 [1] => 1 [2] => 2 )
unset($array[1]);
print_r($array); // return Array ( [0] => 0 [2] => 2 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment