SitePoint Sponsor

User Tag List

Results 1 to 22 of 22
  1. #1
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    How to check if the file exists?

    Hi,

    In a file index.php the links are in the format index.php?content=folder_file_name. The page reloads and the query string tells the page what content to include. So I use explode and implode (and some regex for security) to build the file to be included as folder/file_name.php.

    But what if folder/file_name.php doesn't exist (i.e. the user has changed the URL)? How can I check for this and create an error message for such a case?

    Thanks,

    Rafael

  2. #2
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You can try with is_file
    -- Jelena --

  3. #3
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,426
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about just file_exists?
    http://ca3.php.net/file_exists
    Edit:

    A little late I guess

  5. #5
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually...
    PHP Code:
    if(is_file($file) && is_readable($file)).... 
    is_file checks if this is a file (not directory)
    is_readable tells you if you can read it

  6. #6
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot guys, that solves it. PHP has a function for everything!

  7. #7
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raffles
    Thanks a lot guys, that solves it. PHP has a function for everything!
    I'm still looking for the make_money() function

  8. #8
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You may be surprised how many small businesses will pay whatever you ask for a good PHP developer. From what they tell me, the teens that dabble but don't really know what they're doing are abundant, but experienced programmers that know PHP are more rare.

  9. #9
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Grossman
    You may be surprised how many small businesses will pay whatever you ask for a good PHP developer.
    Is there a list somewhere?

  10. #10
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You can try http://www.getafreelancer.com, it has loads of work offers.

  11. #11
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Grossman
    From what they tell me, the teens that dabble but don't really know what they're doing are abundant, but experienced programmers that know PHP are more rare.
    Gah, I'm 17. Does ~3 years of experimentation count as more than dabbling?
    Probably not

  12. #12
    SitePoint Guru
    Join Date
    Jul 2005
    Location
    Orlando
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by trib4lmaniac
    Gah, I'm 17. Does ~3 years of experimentation count as more than dabbling?
    Probably not
    I started dabbling when I was 18. Finished college and got a job doing it. You're starting down the right path.

  13. #13
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    What did you do at college?

  14. #14
    SitePoint Addict jtresidder's Avatar
    Join Date
    Nov 2003
    Location
    Southampton, UK
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raffles
    You can try http://www.getafreelancer.com, it has loads of work offers.
    I've never found a freelance site yet where the client doesn't pick the guy who's not even answered the basic points in his proposal but is willing to work for $5 an hour. I'd be delighted to be 'shown the light', though.

  15. #15
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jtresidder
    I've never found a freelance site yet where the client doesn't pick the guy who's not even answered the basic points in his proposal but is willing to work for $5 an hour. I'd be delighted to be 'shown the light', though.
    Don't look for $5 deals(w/ some exeptions of course). Those are scam most likely. Good freelancers have enough of work to bother themselves with $5/hour. It's a simple truth -- you have to pay for quality. You'll never get me for $5/h
    Saul

  16. #16
    SitePoint Addict jtresidder's Avatar
    Join Date
    Nov 2003
    Location
    Southampton, UK
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You misunderstand me - I'm saying that I've never found a freelance site worth quoting on, because in my experience the client always goes for price and not quality, and I can't and won't compete with $5/hour.

  17. #17
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raffles
    What did you do at college?
    I know you asked Timmy but... computer science, of course. CNNMoney.com and Salary.com both declared Software Engineer the best job in the US right now. Great pay, flexibility and perks... plus the retiring group is much much larger than the number of people taking up CS in college to replace them.

  18. #18
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Really? Maybe that's the case in the US, but I go to a science-only university in the UK and the computer scientists are the ones that tend to have trouble finding work in their related fields. A lot of them end up doing boring stuff like accounting and management consultancy. Apparently in the UK there's lots of competition between new CS graduates for CS-related jobs. I'll start telling them to consider the US next time someone moans to me about how difficult they're finding getting a job!

  19. #19
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes, the percentage of people enrolling in CS and other engineering majors in the US has dropped. Good jobs seem very easy to find here.. to me at least. I have to work 6 months at a time 3 times as part of the 5 year BS program in CS at Drexel University, and there were companies literally fighting over hiring me. Two of my former employers repeatedly ask me to work for them part time since they know I have a full time job right now, but I already have enough work.

  20. #20
    SitePoint Guru
    Join Date
    Jul 2005
    Location
    Orlando
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I also went to college for Computer Science.

  21. #21
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jtresidder
    You misunderstand me - I'm saying that I've never found a freelance site worth quoting on, because in my experience the client always goes for price and not quality, and I can't and won't compete with $5/hour.
    I guess I am. You're probably right, but keep looking there are really great coders out there.


    Quote Originally Posted by UFTimmy
    I also went to college for Computer Science.
    Me too. But what happened to this thread?
    Saul

  22. #22
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The original question got answered 2 minutes after it was posted, we're safe to hijack.


Bookmarks

Posting Permissions

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