Example #1
0
function check_dirname($path)
{
    global $s;
    $path1 = str_replace("%", $s, $path);
    $path2 = dirname($path1);
    $path3 = str_replace($s, "%", $path2);
    print "dirname({$path}) == {$path3}\n";
}
check_dirname("%foo%");
check_dirname("%foo");
check_dirname("%foo%bar");
check_dirname("%");
check_dirname("...%foo");
check_dirname(".%foo");
check_dirname("foobar%%%");
check_dirname("%%%.%.");
function same($a, $b)
{
    if ($a == $b) {
        print "OK\n";
    } else {
        print "FAIL  {$a} == {$b}\n";
    }
}
if ('/' == $s) {
    same(".", dirname("d:\\foo\\bar.inc"));
    same(".", dirname("c:\\foo"));
    same(".", dirname("c:\\"));
    same(".", dirname("c:"));
} else {
    same("d:\\foo", dirname("d:\\foo\\bar.inc"));
Example #2
0
<?php

function check_dirname($path)
{
    print "dirname({$path}) == " . dirname($path) . "\n";
}
// I actually think that zend gets it wrong on the two commented cases
//	check_dirname("/foo/");
check_dirname("/foo");
check_dirname("/foo/bar");
check_dirname("d:\\foo\\bar.inc");
check_dirname("/");
check_dirname(".../foo");
check_dirname("./foo");
//	check_dirname("foobar///");
check_dirname("c:\foo");
Example #3
0
<?php

/* Prototype: string dirname ( string $path );
   Description: Returns directory name component of path.
*/
$file_paths = array("bar", "/foo/bar", "foo/bar", "/bar", "bar/", "/bar/", "/foo/bar/", "foo/bar/", "/bar/", "/foo/bar.gz", "foo/bar.gz", "bar.gz", "bar.gz/", "/bar.gz", "/bar.gz/", "/foo/bar.gz/", "foo/bar.gz/", "/bar.gz/", "/.gz", ".gz", "/foo/.gz", ".gz/", "/foo/.gz/", "foo/.gz/", "foo" . chr(0) . "bar", "/foo" . chr(0) . "bar/", "/foo" . chr(0) . "bar", "foo" . chr(0) . "bar/", "/foo" . chr(0) . "bar/t.gz");
function check_dirname($paths)
{
    $loop_counter = 0;
    $noOfPaths = count($paths);
    for (; $loop_counter < $noOfPaths; $loop_counter++) {
        echo "\n--Iteration ";
        echo $loop_counter + 1;
        echo " --\n";
        var_dump(dirname($paths[$loop_counter]));
    }
}
echo "*** Testing basic operations ***\n";
check_dirname($file_paths);
echo "Done\n";
?>

Example #4
0
<?php

/* Prototype: string dirname ( string $path );
   Description: Returns directory name component of path.
*/
class temp
{
    function __toString()
    {
        return "Object";
    }
}
$file_path_variations = array("~/home/user/bar", "~/home/user/bar/", "~/home/user/bar.tar", "~/home/user/bar.tar/", "hostname:/home/user/bar.tar", "hostname:/home/user/tbar.gz/", "hostname:/home/user/My Pics.gz", "hostname:/home/user/My Pics.gz/", "hostname:/home/user/My Pics/", "hostname:/home/user/My Pics", "10.5", "/10.5", "/10.5/", "10.5/", "10/10.gz", '0', "0", new temp(), " ", ' ', "", '', NULL, null);
function check_dirname($paths)
{
    $loop_counter = 0;
    $noOfPaths = count($paths);
    for (; $loop_counter < $noOfPaths; $loop_counter++) {
        echo "\n--Iteration ";
        echo $loop_counter + 1;
        echo " --\n";
        var_dump(dirname($paths[$loop_counter]));
    }
}
echo "*** Testing possible variations in path ***\n";
check_dirname($file_path_variations);
echo "Done\n";