$myFile = '/path/to/myFile.txt'; if (!file_exists($myFile)) { print 'File not found'; } else if(!$fh = fopen($myFile, 'w')) { print 'Can\'t open file'; } else { print 'Success open file'; }