Why Mysqli Database Connection not Working Inside a Method or a Function in PHP

Sometimes, I have faced some issues when calling to function inside PHP script, The database connection not working inside the method/function, In case , it will work in MySQL but In the case of Mysqli Connection, we need to pass the connection object as a parameter.

Suppose I have a function below example you can understand easily.

 

Advertisements
Advertisements-1
Advertisements-2
Advertisements-3