A2xA Posted January 31, 2008 Share Posted January 31, 2008 I need to make it where if the file exists, then it won't overwrite it. Also, if the file dosen't exist then it won't do anything but display an error message. I've got the first part I just need to make it where if the file dosen't exist then it will just display an error message. if (file_exists($dir)) { echo "The hub $dir exists already"; } else { code..etc... What else would I do to make both? Quote Link to comment https://forums.phpfreaks.com/topic/88807-solved-if-file-dosent-exist-then-display-message-similar-to-file_exists/ Share on other sites More sharing options...
stlewis Posted January 31, 2008 Share Posted January 31, 2008 if (file_exists($dir)) { echo "The hub $dir exists already"; } else { echo "Your file doesn't exist, this is an error message" } You didn't provide any circumstances under which the file *would* be created, so barring any case where you'd want to, the above code would do what you described. Quote Link to comment https://forums.phpfreaks.com/topic/88807-solved-if-file-dosent-exist-then-display-message-similar-to-file_exists/#findComment-454848 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.