Last active
August 29, 2015 14:16
-
-
Save Aziz-Rahman/53ab8066826a8c9faeab to your computer and use it in GitHub Desktop.
Construtor & Destructor ( OOP PHP )
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 | |
| class motor{ | |
| private $model = "bebek"; | |
| private $warna = "hitam"; | |
| public function __construct(){ | |
| echo "method konstruktor di jalankan"."<br/>"; | |
| } | |
| public function __destruct(){ | |
| echo "method destruktor di jalankan"."<br/>"; | |
| } | |
| public function tampilkanmotor(){ | |
| echo "Motor ini bermodel ".$this->model." dan berwarna ".$this->warna ."<br/>"; | |
| } | |
| } | |
| // Menjalankan perintah | |
| $motorgue = new motor; | |
| $motorgue->tampilkanmotor(); | |
| // ========== Hasil ( Output ) ========= | |
| // method konstruktor di jalankan | |
| // Motor ini bermodel bebek dan berwarna hitam | |
| // method destruktor di jalankan | |
| // ========== *Note ========= | |
| // Construtor adalah sebuah method yang di eksekusi atau di jalankan secara otomatis ketika sebuah objek telah di instansiasi/telah di buat. | |
| // Destructor adalah sebuah method yang di jalankan secara otomatis ketika sebuah objek tidak lagi memiliki fungsi atau saat sebuah objek telah selesai di gunakan . | |
| ?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment