file_exists() returns false, but the file DOES exist

后端 未结 14 1212
一向
一向 2020-12-05 09:40

I\'m having a very weird issue with file_exists(). I\'m using this function to check if 2 different files in the same folders do exist. I\'ve double-checked, they BOTH do ex

14条回答
  •  自闭症患者
    2020-12-05 10:16

    Just my $.02: I just had this problem and it was due to a space at the end of the file name. It's not always a path problem - although that is the first thing I check - always. I could cut and paste the file name into a shell window using the ls -l command and of course that locates the file because the command line will ignore the space where as file_exists does not. Very frustrating indeed and nearly impossible to locate were it not for StackOverflow.

    HINT: When outputting debug statements enclose values with delimiters () or [] and that will show a space pretty clearly. And always remember to trim your input.

提交回复
热议问题