My application is working totally fine in development environment. Once i uploaded it to my production server, i got the following error:
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:
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:
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:
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.
This error stops the application from running, i couldn’t figure it out at all. Any help will be appreciated.
I would guess that your production-server is running with PHP <5.3
Your code uses a anonymous function, they have been introduced in PHP 5.3.0
Solution: create a named function and use it as callback.