问题描述
我试图在 config.PHP 文件中使用 var $db,$db var 是一个准备好的 MysqLi 类 我在我的配置文件中使用这一行
$db = new MysqLiDb ($dbhost,$dbuser,$dbpass,$dbname);
public function save_ship($user = '')
{
global $db;
然后使用我使用的变量:
array(
'ship_heder' => $this->$db->escape($arr[$i]['ship_heder']),'ship_num' => $this->$db->escape($arr[$i]['ship_num']),'ship_type' => $this->$db->escape($arr[$i]['ship_type']),'ship_isuf_cust_no' => $this->$db->escape($arr[$i]['ship_isuf_cust_no']),'ship_address' => $this->$db->escape($arr[$i]['ship_address']),'phone_to_call' => $this->$db->escape($arr[$i]['phone_to_call']),'ship_line' => $this->$db->escape($arr[$i]['ship_lines']['0']['ship_line']),'date_time' => $date->format('d/m/Y H:i:s'),'uid' => $user,);
解决方法
您只需在代码顶部添加以下行,即可将配置文件包含到 functions.php 中:
include_once('config.php');