dirname

(PHP 3, PHP 4 )

dirname -- Restituisce il nome della directory dal percorso indicato

Descrizione

string dirname ( string path)

Data una stringa contenente il percorso di un file, questa funzione restituirà il nome della directory.

Su windows sia gli slash (/) che i backslash (\) vengono utilizzati come caratteri di separazione nei percorsi. In altri ambienti, c'è solo lo slash in avanti (/).

Esempio 1. dirname() example

$path = "/etc/passwd";
$file = dirname ($path); // $file contiene "/etc"

Nota: In PHP 4.0.3, dirname() was fixed to be POSIX-compliant. Essentially, this means that if there are no slashes in path , a dot ('.') is returned, indicating the current directory. Otherwise, the returned string is path with any trailing /component removed. Note that this means that you will often get a slash or a dot back from dirname() in situations where the older functionality would have given you the empty string.

Vedere anche: basename()