Check connection closed

Posted on

Question :

How can I check if a connection has actually been closed?

    $con = new Conexao();

I use a variable to instantiate the Conexao class that is in another file. I would just like to know how I can check if the fecharConex√£o() method actually closed the previously opened connection.

My method to close the connection is this:

public function fecharConexao(){
    return mysqli_close($this->conexao);          

I would just like a notification (just so I know) that the connection is terminated. How do I do this?


Answer :

The function mysqli_close() returns Boolean value

true : indicates successful execution

false : indicates that there was an error.

Basically, just check the return value.

If you return true , the connection has been closed.


Leave a Reply

Your email address will not be published. Required fields are marked *