Welcome Guest, Not a member yet? Register   Sign In
Help with the call of new classess from other files.
#1

[eluser]Unknown[/eluser]
Hi, this's my code from my custom loader:
Code:
class MY_Loader extends MX_Loader {

private $name;

private $emulator;

private $emulator_dir;

private $emulator_info;

  function __construct()
    {
  parent::__construct();
  $this->emulator = ucfirst(strtolower($this->config->item('emulator')));
  $this->emulator_dir = FCPATH.str_replace("/", "\\", APPPATH).'emulators'.DS;
  $this->emulator_info = array('world' => ucfirst(strtolower('world')),'characters' => ucfirst(strtolower('characters')));
   if(file_exists($this->emulator_dir.$this->emulator.DS.$this->emulator.EXT))
   {
    include($this->emulator_dir.$this->emulator.DS.$this->emulator.EXT);
   }
   else {
    show_error('The file '.$this->emulator.EXT.' can\'t be found.');
   }
   if(file_exists($this->emulator_dir.$this->emulator.DS.'world'.DS.$this->emulator_info['world'].EXT))
   {
    include($this->emulator_dir.$this->emulator.DS.'world'.DS.$this->emulator_info['world'].EXT);
   }
   else {
    show_error('The file '.$this->emulator_info['world'].EXT.' can\'t be found.');
   }
   if(file_exists($this->emulator_dir.$this->emulator.DS.'characters'.DS.$this->emulator_info['characters'].EXT))
   {
    include($this->emulator_dir.$this->emulator.DS.'characters'.DS.$this->emulator_info['characters'].EXT);
   }
   else {
    show_error('The file '.$this->emulator_info['characters'].EXT.' can\'t be found.');
   }
  $this->name = $this->emulator;
  $object = strtolower($this->emulator);
  $this->{$object} = new $this->name;
    }

public function initialize()
{
}
}
But when i do:
Code:
$this->{$object}->do_that();
on my Account controller i get that error:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Account::$custom

Filename: controllers/account.php

Line Number: 21


Fatal error: Call to a member function do_that() on a non-object in C:\Servidor\htdocs\application\controllers\account.php on line 21
How i can do $this->{$object} = new $this->name; one time and don't do that anymore?
Please help me, i'm not a proffesional.




Theme © iAndrew 2016 - Forum software by © MyBB