Distinguishing a Folder from a File in PHP
Suppose you have a string containing a path
to a file or folder. With the help of special
functions is_file and is_dir we
can distinguish whether the path points to a file or
to a folder.
They work as follows:
<?php
$path = 'some path';
var_dump(is_file($path)); // true for a file, false for a folder
var_dump(is_dir($path)); // true for a folder, false for a file
?>
Given a path. If the path leads to a folder, output a message about it.
Given a path. If the path leads to a file, output a message about it.