Posted By

1man on 04/25/07


Tagged

php include check error message


Versions (?)

Who likes this?

12 people have marked this snippet as a favorite

willbolton
vali29
hudge
bryandease
silentbob84
chrisaiv
userpiv
voove
clac
ringo380
clacwebstudio
tux-world


Check for Include Files in PHP


 / Published in: PHP
 

Simple way to check see if a file exists and is readable before you include it. Stops nasty error messages onscreen.

  1. <?php
  2. $file = 'includes/filename.inc.php';
  3. if(file_exists($file) && is_readable($file)) {
  4. include($file);
  5. }
  6. ?>

Report this snippet  

You need to login to post a comment.