global $ var does not work in PHP

0

I have the following code:

<?php
$_this =& get_instance();

function ConfiguracoesSistema($coluna){

    global $_this;

    $configuracoes = $_this->db->get('configuracao');

    if($configuracoes->num_rows() > 0){

        return $configuracoes->row()->$coluna;
    }

    return false;
}
?>

I need to get the variable that is outside the $ _ this function and use it inside the System Settings () function. The problem is that it is not accessing, even using the word global . If I put $ _ this = & get_instance (); inside the function, it works. My PHP is version 5.6.

    
asked by anonymous 12.11.2017 / 15:03

1 answer

0

Try calling it into the function without the "global":

<?php
$_this =& get_instance();

function ConfiguracoesSistema($coluna){

    $configuracoes = $_this->db->get('configuracao');

    if($configuracoes->num_rows() > 0){

        return $configuracoes->row()->$coluna;
    }

    return false;
}
?>
    
12.11.2017 / 16:31