Results 1 to 5 of 5

Thread: File()

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    File()

    When getting a file's contents, I do the following:

    Code:
    $info = file('cat' . trim($id) . '.txt') || viewall();
    However, if the file doesn't exist, it still shows the error message before running viewall(); How can I make it now show the error message?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    ricmitch_uk
    Guest
    PHP Code:
    if (is_file($filename)) {
         
    $info file('cat' trim($id) . '.txt') || viewall();
    } else {
         echo 
    "Error!";

    HTH

  3. #3
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    or substitute is_file with file_exists()

    -Matt

  4. #4

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Thank yo's.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    ricmitch_uk
    Guest
    s'ok.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width