Welcome Guest, Not a member yet? Register   Sign In
error when extending CI_Controller
#11

[eluser]InsiteFX[/eluser]
Make sure the code is like he posted with the }); on the end it is the whole spl_ construct.
#12

[eluser]nagata[/eluser]
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;
    }
  }
});
thats how it looks right in the bottom of the config.php file of my.
and still throws error...
#13

[eluser]InsiteFX[/eluser]
It works fine for me, what version of CI are you running?

Because the new CI 3.0 Dev has done away with the EXT and you would need to change it to '.php'

For New CI 3.0 Dev
Code:
/*
| -------------------------------------------------------------------------
| Native spl_autoload_register() - by Kenneth Vogt
| -------------------------------------------------------------------------
|
| Here is an updated version of Phil Sturgeon’s code:
|
| Thanks to Phil Sturgeon and Kenneth Vogt.
|
| NOTE:
| Requires PHP 5.3.+
| As of CI 3.0 Dev - The constant EXT has been removed modified
| should work for all version of CI and PHP 5.3
|
| Place at the bottom of your ./application/config/config.php file.
| -------------------------------------------------------------------------
*/
spl_autoload_register(function($class)
{
if (strpos($class, 'CI_') !== 0)
{
  if (file_exists($file = APPPATH . 'core/' . $class . '.php'))
  {
   include $file;
  }
  elseif (file_exists($file = APPPATH . 'libraries/' . $class . '.php'))
  {
   include $file;
  }
}
});

Updated: 06-15-2012
Now will use '.php. and should work all around now.
#14

[eluser]Ayeyermaw[/eluser]
Nice spot, Kenneth! I never knew that the future of __autoload() was in doubt.
I'll be using your updated code that uses spl_autoload_register() in future

#15

[eluser]InsiteFX[/eluser]
I have updated this please see the above.




Theme © iAndrew 2016 - Forum software by © MyBB