MySQLiconfig.php:
<?php
$MySQLi = new mysqli('localhost','root','123','Database') or die('ERROR');
其他文件:
<?php
require 'MySQLiconfig.php';
function DoAQuery($Query){
$MySQLi->query($Query);
}
错误为:
Undefined variable: MySQLi
变量作用域错误。在需要像global $MySQLi
一样使用的函数中,也可以作为函数参数传递。