Jump to content

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.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.