Welcome Guest, Not a member yet? Register   Sign In
spl_autoload_register Throws an Error in My Production Server
#1

[eluser]fjamal[/eluser]
My application is working fine in development environment. Once i uploaded it to my production server, i got the following error:


Quote:Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /home/fjamal/public_html/*******/anyname/application/config/config.php on line 27

The errors refers to the following code:

Code:
spl_autoload_register(function($class)
{
if (strpos($class, 'CI_') !== 0)
{
  if (file_exists($file = APPPATH . 'core/' . $class . EXT))
  {
   include $file;
  }
  elseif (file_exists($file = APPPATH . 'libraries/' . $class . EXT))
  {
   include $file;
  }
}
});

If i change the above code to the older version as:

Code:
function __autoload($class)
{
if (strpos($class, 'CI_') !== 0)
{
  if (file_exists($file = APPPATH . 'core/' . $class . EXT))
  {
   include $file;
  }
  elseif (file_exists($file = APPPATH . 'libraries/' . $class . EXT))
  {
   include $file;
  }
}
}
I get the following error:

Quote:Fatal error: Class 'Frontend_Controller' not found in /home/fjamal/public_html/********/anyname/application/controllers/home.php on line 4

Explanation of the error: my controller extends from Frontend_Controller which resides in Libraries folder. Frontend_Controller extends from MY_Controller which resides under core folder. For some reason, all these problems in the production environment, i don't get it in my localhost. Hence, home is default controller.

I tried my best, but couldn't figure it out. Any help will be appreciated.


Messages In This Thread
spl_autoload_register Throws an Error in My Production Server - by El Forum - 10-11-2012, 02:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB