Using an instance of PDO class as global variable inside 'query' methods I have one PHP file named database.php:

 try {
     $connection= new PDO(DB_DNS, DB_USER, DB_PASS);
     $connection-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(Exception $e) {
     echo "Error: ".$e-&gt;getMessage();
     die();
}


and I have a user.php with class Users:

require_once(__DIR__."/../includes/config.php");
require_once(__DIR__."/../includes/database.php");

class User
{
    public function pronadjiSveUsere() {
        global $connection;
        $upit = $konekcija-&gt;prepare("SELECT * FROM users");
        $rezultat_upita = $upit-&gt;execute();
        return $rezultat_upita;
    }

    public function find_by_id($id = 0) {
        try {
            global $connection;
            $upit = $konekcija-&gt;prepare("SELECT * FROM users WHERE id = :id");
            $rezultat_upita = $upit-&gt;execute(array($id));
            return $rezultat_upita-&gt;fetch(PDO::FETCH_OBJ);
        } catch (Exception $e) {
            echo $e-&gt;getMessage();
            die();
        }
    }
}


So, you can see that there is a global $connection in each of the methods. Is this bad and why? If so, what would you do, as parameter passing, or with a constructor?
Use global scope for as little as possible. EVER.

Explicitly passing the connection it into the method is always the safe and happy.  It allows for better testing by adhering to dependancy inversion principles.

You could also do it inside of the constructor if the the connection doesn't change during the life of the object, but I'm not a fan of this--I'd prefer a intitial() method to be called after instantiation or explicitly setting it with a set_connection() method.