Created
January 7, 2014 17:56
-
-
Save wwwbruno/8303560 to your computer and use it in GitHub Desktop.
Acesso global de variáveis em uma função
This file contains 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 MinhaClasse { | |
// DECLARAR A VARIÁVEL DE QUALQUER TIPO | |
private $configuracoes = array(); | |
public function __construct() { | |
parent::__construct(); | |
// PASSA UM VALOR PARA A VARIÁVEL EM QUALQUER FUNÇÃO, NESSE CASO, NO CONSTRUCT | |
$this->configuracoes['ativo'] = true; | |
} | |
public function index(){ | |
// ACESSA A VARIÁVEL | |
if($this->configuracoes['ativo']){ | |
echo "Usuário Ativo"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment