#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    20
    Rep Power
    0
    This has been plaguing me for a long time.

    If I include a file using include() or require(), is there a method of checking for the existance of the file before including it, therefore skipping the dreaded error message; or alternatively, supressing the error completely?

    Thanks in advance

    Lanny
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    Alkmaar, The Netherlands
    Posts
    123
    Rep Power
    15
    Just a slip of my mind, so I'm not sure it will work, but try to open the file first, check if this succeeded. If yes close the file and you know it excists. If no, then you know that the file doesn't excist.

    ------------------
    Good luck,
    Bas

    ------------------
    E-mail me at: b.vandermeijden@pecoma.nl
  4. #3
  5. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    61
    Just bear in mind that PHP has a function for just about everything, including checking for the existence of a file:

    $file = "/your_path/your_file";
    if(file_exists($file)){

    etc...

    }
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    20
    Rep Power
    0
    Thanks, the file_exists() function worked perfect. Still curious if there's a way to supress errors in general, or if you need specific solutions like the one above..

    Thanks,


    ------------------
    ---------
    Lanny
    dtm

Similar Threads

  1. Can't move or delete it!
    By Hykinsel007 in forum Windows Help
    Replies: 3
    Last Post: June 15th, 2004, 03:41 PM
  2. Reading files that has certain parrent at once
    By cgi_pro in forum Perl Programming
    Replies: 2
    Last Post: January 29th, 2004, 10:13 PM
  3. uploading files and checking extention
    By tim0 in forum Perl Programming
    Replies: 3
    Last Post: January 19th, 2004, 12:27 AM
  4. how to rename files
    By dxgn in forum Perl Programming
    Replies: 1
    Last Post: January 1st, 2004, 01:10 PM
  5. How can I pack servlet files into a jar file?
    By suryahema in forum Java Help
    Replies: 1
    Last Post: December 18th, 2003, 08:32 AM

IMN logo majestic logo threadwatch logo seochat tools logo