Home / PHP Tips Generated By ChatGPT / Checking File Existence in PHP Check if a file or directory exists before attempting to use it. Source Code if (file_exists('example.txt')) { echo "The file exists"; } else { echo "The file does not exist"; }