Ситуация:
index.php:
<?php
include("foo.php");
include("baz.php");
foo("bar.php");
?>
baz.php:
<?php
$x = 42;
?>
foo.php:
<?php
function foo($p) {
include_once($p); // please dont mind the inclusion hole
}
?>
bar.php:
<?php
echo $x;
?>
Zend уведомление : неопределенная переменная: x
Размещение глобальных $ x; в bar.php удаляет это уведомление, но я понимаю, почему в первую очередь есть уведомление об этом. Это будет означать, что интерпретируемый код будет выглядеть так:
<?php
function foo($p) {
include_once($p); // please dont mind the inclusion hole
}
$x = 42;
// this however, is included by a function...
// does the function's scope influence the stuff it includes?
echo $x; // undefined variable
?>
Мой редактор - пакет Eclipse / Zend.