2.6.2.2. 与文件等有关的函数

2.6.2.2.1. 获得文件名的后缀:getFileSuffix
//eg: from abc.txt got txt
function getFileSuffix($fileName)
{
    $gotInfo = pathinfo($fileName);
    // dirname, basename, extension
    $suffix = strtolower($gotInfo["extension"]);
    return $suffix;
}
                

例 2.4. getFileSuffix使用范例

$fileSuf = $this->getFileSuffix($filename);
                    


2.6.2.2.2. 如何获得某个文件下面的文件(和子文件夹)

相关的代码如下,供参考:

$dirHandler = opendir($fullPath);

while(($filename = readdir($dirHandler)) !== false)
{
    if(($filename == ".") || ($filename == "..") )
    {
        //echo "omit filename=$filename";
        continue;
    }

    echo "filename=". $filename";
}
closedir($dirHandler);