You are here: Re: __autoLoad php5 callback is being triggered for every class ? « PHP « IT news, forums, messages
Re: __autoLoad php5 callback is being triggered for every class ?

Posted by Matthew Weier O'Phinney on 04/29/05 14:21

* php@electroteque.org <php@electroteque.org>:
> I'm experiencing some issues with autoLoad with pear packages. DB_Error is
> contained within the DB.php, but my autoload method is trying to split the
> underscores with forward slashes and then load. Supressing errors with @
> still doesnt work, its triggering a php error. Any ideas ?

Sounds to me like you may need to do a quick call to file_exists()
before trying to load it up. This may involve looping through the
elements in your include_path to build the paths:

// assuming $class = class requested
$file = str_replace('_', '/', $class) . '.php';
$include_path = ini_get('include_path');
$paths = explode(':', $include_path);
$final = '';
foreach ($paths as $path) {
if (file_exists("$path/$file")) {
$final = "$path/$file";
break;
}
}
if (!empty($final)) {
include_once $final;
}

--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:matthew@garden.org | http://vermontbotanical.org

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация