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/
Navigation:
[Reply to this message]
|