We will use the file_exists() function to be aware of the existence of the files, to change them if they are, or to create them.

If there is a file with the name of the file that we will enter the parameter, it will return TRUE, otherwise it will return FALSE. Let’s show it with an example:

<?php
if(file_exists('hello.txt')) {
   echo 'File exists';
} else {
   echo 'File not existing';
}