Last active
February 8, 2018 08:25
-
-
Save KEINOS/b12a889ea822255d0156134da02f3a4a to your computer and use it in GitHub Desktop.
引数で指定したパスがディレクトリかのtrue/falseを返すPHPのユーザー関数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| ======================================================================== | |
| 指定したパスがディレクトリか否かをBOOLEANで返す (2種類) | |
| https://gist.githubusercontent.com/KEINOS/b12a889ea822255d0156134da02f3a4a/raw/function.dir_exists.php | |
| ======================================================================== | |
| */ | |
| /** | |
| * dir_exists function. (Type A) | |
| * | |
| * is_dir()の語感互換関数 | |
| * | |
| * @access public | |
| * @param string $path_dir | |
| * @return bool | |
| */ | |
| if (! function_exists('dir_exists')) { | |
| function dir_exists($path_dir) | |
| { | |
| return is_dir((string) $path_dir); | |
| } | |
| } | |
| /** | |
| * dir_exists function. (Type B) | |
| * | |
| * is_dir()の語感互換関数 | |
| * | |
| * @access public | |
| * @param string $path_dir | |
| * @return bool | |
| */ | |
| if (! function_exists('dir_exists')) { | |
| function dir_exists($dir_name = false) | |
| { | |
| if (! $dir_name) { | |
| return false; | |
| } | |
| $dir_name = realpath(trim($dir_name)); | |
| if (file_exists($dir_name)) { | |
| return ( is_dir($dir_name) ) ? true : false; | |
| } else { | |
| return false; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment