Наткнулся на проблему:
Автоматически присоединяю классы при помощи spl_autoload_register
файл incs/boot.inc:
<?php
$GLB = array(1,2,3);
// Auto load class files
spl_autoload_register('AutoLoadClass');
function AutoLoadClass($className) {
$FileName = PATH . 'incs/' . strtolower($className) . '.inc';
if(file_exists($FileName))
include_once $FileName;
}
?>
а в фале index.php:
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/incs/boot.inc';
$db = new MySQL();
print_r($GLB); // <-- Place 1
?>
а в фале incs/mysql.php:
<?php
print_r($GLB); // <-- Place 2
class MySQL {
...
Так вот в Place 2 ошибка:
Notice: Undefined variable: GLB in /var/www/***/data/www/***/incs/mysql.inc on line 2
Почему так? ведь вроде оба файла (boot.inc и mysql.inc) преинклюжены к index.php?