phpmanifest.cache

getFilename function - Manifest File for cache


I'm following an tutorial in Johnathan Stark's Building iPhone app book. It's teaching how to use a manifest file to do offline storage. As you can see, it's searching all the directories and outputting the file names. My question is about the 0 and the 1 in this line

getFilename(), 0, 1

I know what getFilename does, but what is the 0 and the 1 doing?

Thanks for your help.

<?php
header('Content-Type: text/cache-manifest');
echo "CACHE MANIFEST\n";
$hashes = "";
$dir = new RecursiveDirectoryIterator(".");
foreach(new RecursiveIteratorIterator($dir) as $file) {
    if ($file->IsFile() && $file != "./manifest.php" && substr($file->getFilename(), 0, 1) != ".") {
        echo $file . "\n";
        $hashes.= md5_file($file);
    }
}
echo "# Hash: " . md5($hashes) . "\n";

Solution

  • substr($file->getFilename(), 0, 1)
    

    0 and 1 are parameters to the substr() call. They specify to get the first character from getFilename()'s return value.