Usually some people make database connection class with constructor of connection. It means that when you initialize the object of that class, the constructor is executed automatically.
For example here is Database class
<?php
class db
{
public $conn;
public function __construct()
{
$this->conn=mysqli_connect("localhost","root","","prepared");//A constructor is a function that is executed after the object has been initialized (its memory allocated, instance properties copied etc.). Its purpose is to put the object in a valid state.
if($this->conn)
{
echo "";
}
else{
echo $this->conn->error;
}
}
}
$db = new db();
?>
Child class
include("db.php");
class childclass extends db
{
public function database_query()//here you don't need to put $conn in parameters
{
$sql = "SELECT * FROM table";
$result = $this->conn->query($sql);//Here you can see how we can call conn from db class
print_r($result);
}
}
I hope you got my point.