How to make sure a file exists before requiring it?

Hello,

My script contains included scripts. I use require_once(). If the script is not there, I get an error. I’d like to know if there is a way to check if the file exists before requiring it.

I expect people to question my logic: just so you know, I’m working within a wordpress environment, so I just want to make sure that a wp file change name won’t affect my code.

:slight_smile:

file_exists

If you want to be able to recover then you use include_once() which throws a warning upon failure whereas require which throws a fatal error and stops.