Created
December 3, 2010 01:39
-
-
Save georgemendonca/726441 to your computer and use it in GitHub Desktop.
Construtores e Destrutores em 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 | |
| /** | |
| * Exemplo de construtor e destrutor | |
| * @author george.mendonca | |
| */ | |
| Class ConstrutorDestrutor | |
| { | |
| private $a; | |
| private $b; | |
| /** | |
| * O construtor da classe inicializa os | |
| * valores dos atributos do objeto caso | |
| * necessário. | |
| */ | |
| public function __construct($a, $b) | |
| { | |
| $this->a = $a; | |
| $this->b = $b; | |
| } | |
| public function __destruct() | |
| { | |
| /** | |
| * Libera o espaço em memória | |
| * reservado para o objeto no | |
| * encerramento do script ou quando | |
| * chamado explicitamente. | |
| */ | |
| $this->a = null; | |
| $this->b = null; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment