的config.php不能包含在類中的PHP文件構建
<?PHP
define('DB_SERVER','localhost');
define('DB_USER','root');
DEFINE('DB_PASSWORD','');
DEFINE('DB','bank');
$conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
edit_action.php
<?php
#Edit User code
print_r($_POST);
Class edit_user
{
public function __construct()
{
include 'config.php';
#including config file
}
public function edit()
{
print_r($_POST);
#All the updated code defined here
}
}
當我嘗試執行此它給出錯誤的代碼,不包括配置文件。
錯誤:未定義的變量:康恩在edit_action.php
你可以分享你的'config.php'嗎? –