Last active
August 8, 2019 15:11
-
-
Save cesarkohl/d22f8cef512e2461348a781bedf9c773 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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