We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

1man on 04/25/07


Tagged

php include check error message


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

willbolton
vali29
hudge


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.