(PHP 4, PHP 5, PHP 7)
dirname — ����·���е�Ŀ¼����
$path
) : string����һ��������ָ��һ���ļ���ȫ·�����ַ���������������ȥ���ļ������Ŀ¼����
path
һ��·����
�� Windows �У�б�ߣ�/���ͷ�б�ߣ�\������������Ŀ¼�ָ�������������������б�ߣ�/����
���� path �ĸ�Ŀ¼��
����� path
��û��б�ߣ���һ���㣨'.'������ʾ��ǰĿ¼�����ص��ǰ�
path
�н�β��
/component�����һ��б���Լ����沿�֣�ȥ��֮����ַ�����
�汾 | ˵�� |
---|---|
5.0.0 | dirname() �IJ����� PHP 5.0.0 �濪ʼ�Ƕ����ư�ȫ�ġ� |
4.0.3 | ������汾�У�dirname() ������Ϊ POSIX ���ݡ� |
Example #1 dirname() ����
<?php
echo "1) " . dirname("/etc/passwd") . PHP_EOL; // 1) /etc
echo "2) " . dirname("/etc/") . PHP_EOL; // 2) / (or \ on Windows)
echo "3) " . dirname("."); // 3) .
?>
Note:
dirname() operates naively on the input string, and is not aware of the actual filesystem, or path components such as "..".
Note:
dirname() is locale aware, so for it to see the correct directory name with multibyte character paths, the matching locale must be set using the setlocale() function.
Note:
Since PHP 4.3.0, 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.
������淢���仯�����ӣ�
<?php
// PHP 4.3.0 ��ǰ
dirname('c:/'); // ���� '.'
// PHP 4.3.0 �Ժ�
dirname('c:/x'); // ���� 'c:'
dirname('c:/Temp/x'); // ���� 'c:/Temp'
dirname('/x'); // ���� '\'
?>