Hall of Famer Posted July 7, 2012 Share Posted July 7, 2012 Well I am trying to load a project I was developing into Netbeans. It looks nice, but it gives this one annoying error that comes from nowhere. In my script there is a file called inc/init.php which is included in every publicly accessible script files. This init.php defines variables such as $system, $lang, $db, $page and $registry, which is shown as below: <?php $dir = (defined("SUBDIR"))?"../":""; // Include config file, which contains constants such as DBHOST, DBNAME for later use $config = "{$dir}inc/config.php"; require $config; // Include loader file, which defines autoloader method used to replace __autoload() function $loader = "{$dir}classes/class_loader.php"; require $loader; $loader = new Loader; // Instantiating core objects $system = new System; $system->initialize(); $lang = new Language(); $lang->load(); $db = new Database(DBHOST, DBNAME, DBUSER, DBPASS, PREFIX); $page = new Page(); // Use singleton registry to store statically accessible objects, these can be used in every class file then $registry = new Registry(); $registry->assign($system); $registry->assign($lang); $registry->assign($db); $registry->assign($page); ?> In a publicly accessible script file, it looks like this:(the below code shows the simplest "hello world" example) <?php require "inc/init.php"; $page->settitle("Hello World!"); $page->setcontent("This is an example of the simplest hello world"); $system->output($page); ?> Nonetheless, in Netbeans I am getting errors 'this variable is not declared' whenever I use a variable(such as $system and $page) defined in an included file like init.php. It is quite annoying, do anyone of you know how I can get rid of this error? Thx. Link to comment https://forums.phpfreaks.com/topic/265339-netbeans-cannot-recognize-variables-from-included-files/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.