Return from one function in another Class

0

I want to call the function data_hora_atual() in this session class:

class sessao {
    function fazSessao($conexao){

    }
}

class administracao {
    function data_hora_atual($par,$conexao){
        date_default_timezone_set('America/Sao_Paulo');

        return array();
    }
}
    
asked by anonymous 06.04.2018 / 21:37

1 answer

0

Considering that you will use data_hora_atual within fazSessao , just for example:

Two alternatives:

Turn the function into static:

function static data_hora_atual($par,$conexao){ }

And in Class session:

function fazSessao($conexao){
    administracao::data_hora_atual($par, $conexao)
}

You can also extend your administration class:

class sessao extends administracao {
    function fazSessao($conexao){
        $this->data_hora_atual($par, $conexao);
    }
}
    
06.04.2018 / 21:52