Re: Autoloading

From: Date: Thu, 26 Jan 2012 15:21:59 +0000
Subject: Re: Autoloading
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-316403@lists.php.net to get a copy of this message
On Jan 26, 2012, at 10:15 AM, Stuart Dallas wrote: > On 26 Jan 2012, at 14:44, Floyd Resler wrote: > >> I am using __autoload for my site which is conflicting with the autoloading of PHPExcel. I >> tried using spl_autoload_register thinking that might be the way to go but when I tried I got a >> "cannot be redeclared" error. I include my autoload script (include_once >> "../../lib/autoload.php";) and my autoload.php script looks like this: >> <? >> function __autoload($class_name) { >> $path="../../lib/class.$class_name.php"; >> if(file_exists($path)) { >> require_once $path; >> } >> } >> ?> >> >> As stated, when I change __autoload to spl_autoload_register I get the can't be >> redeclared error. Any ideas? > > spl_autoload_register is a function you call, not a function you define. See the example on the > manual page for that function. > > -Stuart > Yeah, silly me for not reading the manual page! :) It's amazing how well it works when you follow the instructions! Thanks! Floyd

« previous php.general (#316403) next »