我有一个页面,需要包含functions.php,并显示另一个的内容。这个其他页面也包含了functions.php,它给出了错误。
/index.php(..htaccess重定向到这里)
include_once '/themes/default/views/layouts/main.php';
function showContent() {
[...]
}
/themes/default/views/layouts/main.php
include_once('/includes/functions.php'); //why this include doesn't work for login.php
// html and php code
showContent(); //will include login.php
/views/site/login.php
include_once('/includes/functions.php');
//php and html code
所以我得到未定义的变量通知和其他错误...而且我不明白为什么如果我从login.php中删除包含也会给出错误...我的意思是问题是要有2倍的include_once。
我该如何解决这个问题?
泰!
编辑:添加错误文件:
的login.php
include('includes/functions.php');
sec_session_start();
if (login_check($mysqli) == true) {
$logged = 'in';
} else {
$logged = 'out';
}
?>
$ mysqli在db_connect.php中创建,包含在functions.php
中db_connect.php
include_once 'config.php';
$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);