Skip to content

Instantly share code, notes, and snippets.

@wwwbruno
Created January 7, 2014 17:56
Show Gist options
  • Save wwwbruno/8303560 to your computer and use it in GitHub Desktop.
Save wwwbruno/8303560 to your computer and use it in GitHub Desktop.
Acesso global de variáveis em uma função
<?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