Frage

I receive a lot of undefined variable errors in zend studio 10.

I have a php file like this :

file var.php

<?php
$functions = $root."/requires/functions.php";
$top_utf = $root."/requires/top_utf.php" ;
$database = $root."/requires/db.php" ;
$footer = $root."/requires/pageFooter.php" ;
?>

Now if I use the following code in a php file, zend studio shows Undefined Variable errors on all the require_once lines. (If I access this page with a browser the page is displayed as expected and it works perfectly.)

<?php
$root = $_SERVER['DOCUMENT_ROOT'];
require_once($root."/requires/vars.php") ;
require_once($functions);
require_once($top_utf);
require_once($database);
require_once($footer);
?>

Doesn't Zend Studio recognize the declared variables in an included file (var.php in this case)? Since $functions and $top_utf variables are defined in var.php, I believe I shouldn't receive these errors. Any kind of advice is much appreciated.

War es hilfreich?

Lösung

If you're going to use this style of programming, which I'm not advocating, I suggest you define constants in your var.php instead

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top