Skip to content

Instantly share code, notes, and snippets.

@yuya-matsushima
Created April 11, 2011 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuya-matsushima/914198 to your computer and use it in GitHub Desktop.
Save yuya-matsushima/914198 to your computer and use it in GitHub Desktop.
SplFileInfoのisFile(),isLink()の挙動がおかしい?
<?php
//ファイルは実際に存在
$dat = '../sample.dat';
$file = new SplFileInfo($dat);
switch(TRUE)
{
case $file->isDir():
echo 'ディレクトリです。', "<br>";
case $file->isExecutable():
echo '実行可能です。', "<br>";
case $file->isFile():
echo 'ファイルです。', "<br>";
case $file->isLink():
echo 'リンクです。', "<br>";
case $file->isReadable():
echo '読み取り可能です。', "<br>";
case $file->isWritable():
echo '書き込み可能です。', "<br>";
}
//Result
//ファイルです。
//リンクです。
//読み取り可能です。
//書き込み可能です。
//リンク…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment