Reply to Re: How to see if a PEAR package exists?

Your name:

Reply:


Posted by Toby A Inkster on 12/08/07 11:05

Jerry Stuckle wrote:

> including a file which does not exist will not throw an exception.

My general method is:

$old_error_reporting = error_reporting(E_ERROR);
include 'Foo.php';
error_reporting($old_error_reporting);

This will include a file without issuing any warnings if it's missing.

And then you just perform a test to see if something that you know is
defined in Foo.php has successfully been defined. e.g.

echo class_exists('Foo') ? 'Foo.php found' : 'Foo.php not found';

Some will simply recommend checking to see if the file Foo.php exists
before including it, but thanks to the include_paths setting, that's
easier said than done!

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 21:34.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/

[Back to original 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

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