file_exists

Published June 12, 2017 by Anil Kumar Vishwakarma

file_existsChecks whether a file or directory exists

Testing whether a file exists


<?php
$filename 
'/path/to/foo.txt';

if (file_exists($filename)) {
echo 
“The file $filename exists”;
} else {
echo 
“The file $filename does not exist”;
}
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: