Why does specifying a different directory path still display the size of the main directory in PHP?

When specifying a different directory path in PHP, if the code to calculate the directory size is not updated to reflect the new path, it will still display the size of the main directory. To solve this issue, you need to modify the code to calculate the size of the specified directory path instead.

function getDirectorySize($path){
    $total_size = 0;
    $files = scandir($path);

    foreach($files as $t) {
        if (is_dir(rtrim($path, '/') . '/' . $t)) {
            if ($t<>"." && $t<>"..") {
                $size = getDirectorySize(rtrim($path, '/') . '/' . $t);
                $total_size += $size;
            }
        } else {
            $size = filesize(rtrim($path, '/') . '/' . $t);
            $total_size += $size;
        }
    }

    return $total_size;
}

$directory_path = "/path/to/your/directory";
$size = getDirectorySize($directory_path);
echo "Size of directory {$directory_path} is: " . $size . " bytes";