How to include only if file exists

Solution 1:

if(file_exists('file.php'))
    include 'file.php';

That should do what you want

Solution 2:

Try using file_exists()

if(file_exists($file)){
  include $file;
}