Jump to content

Netbeans cannot recognize variables from included files


Recommended Posts

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.