我最近在笔记本电脑上安装了新版本的 XAMPP。我将一个 Web 应用程序从我的桌面移到了我的笔记本电脑上,但这里的东西无法正常工作。我发现必需和包含文件中的变量被视为“未定义”。php.ini 设置有什么不同吗?
我有以下设置。
index.php
includes/config.php
includes/include.php
index.php
需要includes/include.php
哪个includes/config.php
需要。但是, 中的变量config.php
在include.php
.
想法?
配置文件
<?php
// WEBSITE INFO
DEFINE ('WEBSITE_URL', 'http://localhost/xion/'); // Database name.
DEFINE ('WEBSITE_MAIN', 'index.php'); // Website main page.
// MySQL
DEFINE ('DB_NAME', 'xion'); // Database name.
DEFINE ('DB_USER', 'admin'); // Database user.
DEFINE ('DB_PASS', 'admin'); // Database password.
DEFINE ('DB_HOST', 'localhost'); // Database host.
DEFINE ('DB_PFIX', 'xion_'); // Table prefix for multiple installs.
?>
包含.php
<?php
require 'config.php';
// MySQL Config
$db_connect = mysqli_connect (DB_HOST, DB_USER, DB_PASS, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );
// SmartyPHP Config
require 'smartyphp/libs/Smarty.class.php';
$smarty = new Smarty();
$smarty->caching = 0;
$smarty->template_dir = 'templates/default';
$smarty->compile_dir = 'templates_c';
// User Permissions
session_start();
if ( isset($_SESSION['user']) ) {
$logged_in = "TRUE";
$smarty->assign('logged_in', $logged_in);
foreach ( $_SESSION['user'] as $key => $value ) {
$smarty->assign($key, $value);
}
} else {
$logged_in = "FALSE";
$smarty->assign('logged_in', $logged_in);
}
?>