php true方法使用mysqli连接到处[关闭]

I have a MySQLi connection object to connect to mysql as this :

require_once('config.php');


//new mysqli object
$mysqli = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE);

/* check connection */
if ($mysqli->connect_errno) {
    printf("Connect failed: %s
", $mysqli->connect_error);
    exit();
}

and I've included this file into any files to have connection

Is it right way? I think in my every files , I will have new connection to MySQL.

Php does not have control over how many connections you will have. Mysql manages the pool internally and will allocate connections according to the max_connections parameter for example (not sure of exact parameter name).

Creating 10 connection objects does not mean having 10 opened connections.